I have a java.lang.String
that may contain any character possible, is there a easy way to sanitize the string (for example with an additional class that can do that?) and remove all "dangerous" characters for a later java.util.regex.Matcher
or regex processing (e.g. $, ^, ...)?
You can use
Pattern.quote(string);
to escape your string for Regex.
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