BUG:
I have the following String:
String keyword = '\AMore\s*Code\Z';
and i want to replace regexs as following:
keyword.replace("[\\A", "").replace("[\\Z", "").replace("[\\s*", " ") : "";
But i got the following error:
java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 2
FIX:
Use the java.util.regex.Pattern to escape special characters in regex:
keyword = Pattern.compile("\\\\A").matcher(keyword).replaceAll(" ");
No comments:
Post a Comment