Since I reported the bug, I thought I should at least also investigate it a bit further. I've been able to further simplify the pattern to reproduce the bug (see also on ideone.com).
System.out.println( "abaab".matches("(?x) (?: (?=(a+)) \\1 b )* x") ); // StringIndexOutOfBounds: -1The out of bounds index is the difference in length between the first and the second
a+
(e.g. "aabaaaaab"
gets -3).Note that using reluctant
*?
or possessive *+
simply returns false
. Only the greedy *
raises the exception.It looks like the problem is triggered by the attempt to backtrack a greedy repetition when there's a reference to a capturing group inside a lookahead.
No comments:
Post a Comment