Java How To Remove Vowels from a String
Remove Vowels from a String
Delete all vowels (a, e, i, o, u
) from a string (case-insensitive).
Example
String text = "Hello Java";
String result = text.replaceAll("[aeiouAEIOU]", "");
System.out.println(result);
Explanation: The regular expression [aeiouAEIOU]
matches all vowels (both lowercase and uppercase). Replacing them with an empty string removes them. For "Hello Java"
, the result is "Hll Jv"
.