But this solution has the same problem that La battle mentions in another comment: if a word contains a valid "ie" string, it will be transformed into "ei" incorrectly. I was testing the sentence He haD iEght ShOTs of CAffIEne. thEn hE dIeD and the last "dIeD" was being transformed into "deid". One option could be extending the function to check a dictionary or make a call to an API to verify the word is valid, but that could be a pain too.
Another possible extension would be to split not only by ., but also by other sentence delimiters such as ? or !.
JavaScript
But this solution has the same problem that La battle mentions in another comment: if a word contains a valid "ie" string, it will be transformed into "ei" incorrectly. I was testing the sentence
He haD iEght ShOTs of CAffIEne. thEn hE dIeD
and the last "dIeD" was being transformed into "deid". One option could be extending the function to check a dictionary or make a call to an API to verify the word is valid, but that could be a pain too.Another possible extension would be to split not only by
.
, but also by other sentence delimiters such as?
or!
.Also, if your sentence contains nouns such as
He haD iEght ShOTs of CAffIEne in Paris. thEn hE dIeD
, you will loose the upperP
ofParis
.