I'm attempting to count the number of syllables in a given word using regex. I've referred to some other posts on stack overflow but am getting strange behavior when I run my program.
Here is what I'm attempting
int n=0;
Pattern p = Pattern.compile("[aeiouy]+[^$e]");
Matcher m = p.matcher("Harry");
while(m.find()) {
n++;
}
System.out.println(n);
Now, it's printing out 1. But there is both an "a" and "y" within the string. Where have I gone wrong?