Reputation: 8631
currently using this regex: s.replaceAll("[^a-zA-Z0-9]", "");
however it removes values I need such as @ . , !
how can I include these in my regex so they do not get replaced with empty strings.
Cheers
Upvotes: 2
Views: 2972
Reputation: 311338
Just add them to the regex. Note that .
is a special character, so you'd have to escape it:
String newString = s.replaceAll("[^a-zA-Z0-9!@\\.,]", "");
Upvotes: 4