Let me also add to these good answers a solution that does not involve comparing regular expressions or StringBuilders/ long or, so that you can choose the one that best suits your needs.
public String doubleVowel(String str)
{
String vow = "aeiou";
for (int i = 0; i < str.length(); i++) {
if (vow.indexOf(str.charAt(i)) != -1) {
str = str.substring(0, i + 1) + str.substring(i++, str.length());
}
}
return str;
}
source
share