Java Regular Expression to remove all vowels from a string

dshrenik
dshrenik used Ask the Experts™
on
Please give me the most efficient way to do this (even if does not require RegEx).
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:
s= s.replaceAll("(?i)[aeiou]", "");
regex is the easiest,

str.replaceAll( "[aeiou]", "")  ;
try this String.replaceAll

package com.pocs.one;

public class Regex2
{
	public static void main(String[] args)
	{
		String input = "afasdf3bqerfbaefaberf";
		
		System.out.println(input.replaceAll("a|A|e|E|i|I|o|O|u|U", ""));
	}
}

Open in new window

Top Expert 2016

Commented:
:)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial