String foo = "a3#4#b";
String afterPunctutationRemoval = foo.replaceAll("[,.;:?!'-_\"/()\\{}]", "");
System.out.println(afterPunctutationRemoval);
it gives me “a##b” as a result, can someone explain me why?
Shouldn’t it return the string as it is?
Your character class contains the range
'.._which matches digits as well.Put the
-at the start or end of the character class:or escape it: