In java, how can I remove the vowels, these are "a", "e", "i", "o" and "u

How can I remove vowels from a string except for the vowel at the end of a word?

For example, "Please come to my party"

To return "Plse cme to my prty"

+6
source share
2 answers
 string.replaceAll("[aeiou]\\B", "") 

Reads: matches all vowels ( [aeiou] ), which are not followed by "end of word" ( \\B ). For more information read the Javadoc at java.util.regex.Pattern

+15
source

Turn the string into a char array.

Iterate through it.

Add each character to StringBuilder if the next character is not an alphabetic character.

+3
source

Source: https://habr.com/ru/post/888520/


All Articles