Hi,
Just wondering if anyone has any experience with / suggestions for the following:
String s = "(\\QschoolÔ\\E)";
Pattern p = Pattern.compile(s, Pattern.CANON_EQ);
throws
Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed group near index 38
(\Qschool(?:O?\|È\|O\?)E\b)?
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.accept(Unknown Source)
at java.util.regex.Pattern.group0(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at main(Tester.java:153)
Take off the CANON_EQ and it works fine - it looks like CANON_EQ causes the pattern to be rewritten and it missed the '\' before the 'E', so the '\Q' group is never terminated.
If there is another character besides the high order character before the \\E, it works:
String s = "(\\QschoolÔs\\E)";
If it isn't in a group, it also works:
String s = "\\QschoolÔ\\E";
Am I overlooking something?
javac -version
javac 1.6.0_21
java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) 64-Bit Server VM (build 17.0-b17, mixed mode)
Thanks.