replace multiple characters with replaceAll

I have this Java code:

String payload = "women's tops.com";

String domainf = payload.replaceAll("\\s+", "");
String domain = domainf.replaceAll("'", "");

I need to get "womenstops.com"

How I can do this with one method replaceAll?

>Solution :

"women's tops.com".replaceAll("['\\s+]", "")

will give womenstops.com

Leave a Reply