<triVinci@gmail.com> wrote in message
news:1165931275.068340.114180@f1g2000cwa.googlegroups.com...
Thanks for taking the time to write that up and respond. It helped me
shed a little more light on the issue. It's not the "\\" that causes
the problem, but rather "\\Q". I've modified RegX and regex.txt a bit
to highlight the problem. Runtime output is from 1.4, 1.5, and 1.6
(with the Exception pasted in).
I think you found a bug. Here's an SSCCE that more readily demonstrates
the problem:
<SSCCE>
public class RegExpTest {
public static void main(String args[]) {
System.out.println("Java Version " +
System.getProperty("java.specification.version"));
System.out.println("----------------");
{
// This works
String regex = "G\\\\A";
Pattern pat = Pattern.compile(regex);
}
{
// This works
String regex = "G\\\\B";
Pattern pat = Pattern.compile(regex);
}
{
// This fails
String regex = "G\\\\Q";
Pattern pat = Pattern.compile(regex);
}
}
}
</SSCCE>
It probably has to do with the fact that \Q and \E are used for "super
quoting" in regular expressions, and the parser looks for \Q before escaping
all the \\s first.
So go ahead and file the bug report at Sun's.
- Oliver
Hmmm..
but 1.6 doesn't.
but 1.4 doesn't.