Search code examples
javareplaceall

Java Replace All?


I´m trying to replace some characters in my string but it isnt working. Can you please help me?

My code is:

String test = "ABC?!";
test = test.replaceAll("\\?","");
test= test.replaceAll("\\!, "");

Thank you so much for helping me.


Solution

  • Try str.replaceAll("[?!]", "");