I have comma separated list of regular expressions:
I have done a split on the comma. Now I’m trying to match this regex against a generated password. The problem is that
Pattern.compile does not like square brackets that is not escaped.
Can some please give me a simple function that takes a string like so:
[0-9] and returns the escaped string
You can use
From the docs:
public static String quote(String s)
Returns a literal pattern
Stringfor the specified
This method produces a String that can be used to create a Pattern that would match the string s as if it were a literal pattern.
Metacharacters or escape sequences in the input sequence will be given no special meaning.