Tuesday, 17 September 2013

How to Java Regex to match everything but specified pattern

How to Java Regex to match everything but specified pattern

I am trying to match everything but garbage values in the entire
string.The pattern I am trying to use is:
^.*(?!\w|\s|-|\.|[@:,]).*$
I have been testing the pattern on regexPlanet and this seems to be
matching the entire string.The input string I was using was:
Vamsi///#k03@g!!!l.com 123**5
How can I get it to only match everything but the pattern,I would like to
replace any string that matches with an empty space or a special charecter
of my choice.

No comments:

Post a Comment