I was writing some code to change words into pig Latin. I wanted to change the rules abit and only change words that
started with consonants. Glowball responded to my initial question with:
var Pattern = new Object();
Pattern.vowels = /^[aeiouAEIOU]/;
var foundVowel = Pattern["vowels"].exec(theWord);
//assume var theWord holds the word
if (!foundVowel)
{//change word
}
I think I understand the first two lines: creating a new Object called Pattern and then using pattern matching, assigning the lowercase and uppercase vowels to Pattern.vowels. The third line I am confused on. I am not really sure what it is doing. Does "vowels" in brackets need to be included. And I am not familiar with exec. Does this third line of code need to be typed in exactly? When I tried the code it did not work. Could someone explain in GORY detail this third line starting with var foundVowel or offer another solution.
Thanks.
started with consonants. Glowball responded to my initial question with:
var Pattern = new Object();
Pattern.vowels = /^[aeiouAEIOU]/;
var foundVowel = Pattern["vowels"].exec(theWord);
//assume var theWord holds the word
if (!foundVowel)
{//change word
}
I think I understand the first two lines: creating a new Object called Pattern and then using pattern matching, assigning the lowercase and uppercase vowels to Pattern.vowels. The third line I am confused on. I am not really sure what it is doing. Does "vowels" in brackets need to be included. And I am not familiar with exec. Does this third line of code need to be typed in exactly? When I tried the code it did not work. Could someone explain in GORY detail this third line starting with var foundVowel or offer another solution.
Thanks.