开发者

In java how I can delete Vowels are 'a', 'e', 'i', 'o' and 'u

开发者 https://www.devze.com 2023-03-06 19:29 出处:网络
How can I delete vowels from a String except the vowel at the end of word? For example\"Please come to my party\"

How can I delete vowels from a String except the vowel at the end of word?

For example "Please come to my party"

To return "Plse cme to my 开发者_运维百科prty"


string.replaceAll("[aeiou]\\B", "")

Reads: Match all vowels ([aeiou]) that are not followed by an "end of word" (\\B). For more information read the Javadoc on java.util.regex.Pattern


Turn the String into a char array.

Iterate through it.

Append each character to a StringBuilder, unless the next character is an alphabetic character.

0

精彩评论

暂无评论...
验证码 换一张
取 消