It seems that having a string that contains the characters {
or }
is rejected during regex processing. I can understand that these are reserved cha
Use Pattern.quote(String):
public static String quote(String s)
Returns a literal pattern
String
for the specifiedString
.This method produces a
String
that can be used to create aPattern
that would match the strings
as if it were a literal pattern.Metacharacters or escape sequences in the input sequence will be given no special meaning.
Parameters:
s
- The string to be literalized
Returns:
A literal string replacement
Since:
1.5