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++;
}