Finding Vowels in a string

int count = 0;
String str = "Abcdefg";
      
if (str.length() > 0) {
    Pattern vowelPattern = Pattern.compile("[a/Ae/Ei/Io/Ou/U]");
    Matcher vowelMatcher = vowelPattern.matcher(str);

     while (vowelMatcher.find()) 
        count++;
     }

Leave a comment