jQuery-Slugify-Plugin icon indicating copy to clipboard operation
jQuery-Slugify-Plugin copied to clipboard

The Pig Latin function in the example doesn't work very well

Open pmcelhaney opened this issue 11 years ago • 0 comments

It gets the point across but sometimes puts letters in the wrong place. Who wants to take a stab at improving this guy?

var pigLatin = function(str) {
    return str.replace(/(\w*)([aeiou]\w*)/g, "$2$1ay");
}

Hint: it would probably be easier to ditch the regular expression and just loop over the letters until you find a vowel.

pmcelhaney avatar Oct 07 '14 13:10 pmcelhaney