I try to keep only letter and number
String str = "it's too hard & jean say";
String strNew = str.replaceAll("[^A-Za-z0-9\\s]", "");
I tried with this code but space is not removed.
so i search a way to remove it.
It does not remove spaces because you have specified to replace everything except for letters (A-Za-z
), numbers (0-9
), and spaces (\\s
) with empty string.
Just remove the \\s
and it should also replace spaces with empty string.
String strNew = str.replaceAll("[^A-Za-z0-9]", "");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With