Replacing all non-alphanumeric characters with empty strings
is there a way to completely replace any non-alphanumeric char with an empty string
i found something like this:
Code:
return value.replaceAll("\\W", "");
Code:
return value.replaceAll("[\\W]|_", "");
but i dont really understand what they both do, so can you explain them to me and what the difference is please
Re: Replacing all non-alphanumeric characters with empty strings
Have you read the documentation of java.util.regex.Pattern?
Here's another learning resource: Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns
db