I have the following Regex: [<>\\]|\p{C}
How can I create as String with that in Java, the problem is in the Regex are two backslashes:
String reg="[<>\\]|\p{C}"; // this gets error
Pattern p = Pattern.compile(reg);
I have the following Regex: [<>\\]|\p{C}
How can I create as String with that in Java, the problem is in the Regex are two backslashes:
String reg="[<>\\]|\p{C}"; // this gets error
Pattern p = Pattern.compile(reg);
Just escape the backslash, with a backslash :
String reg="[<>\\\\]|\\p{C}";
* lose their special meanings inside character classes, but escape sequences like \s don't, so the backslash is always special."[\\p{C}<>\\\\]"