I am trying to create a Latin pig converter that breaks a string into the first vowel and switches the first substring to the second (e.g. dog β ogd).
The following regular expression code works for single vowel strings, however, when trying to translate a word with multiple vowels, it breaks the string into the last vowel:
string.replace(/(\w+)([aeiou]\w+)/i, '$2$1')
Running this code in the word "value" results in "ingmean" (splitting on "i"), while I expect to return "eaningm" (splitting on "e")
Thanks!
source share