Regex look-behind without obvious maximum length in Java

Glancing at the source code for Pattern.java reveals that the '*' and '+' are implemented as instances of Curly (which is the object created for curly operators). So,

a*

is implemented as

a{0,0x7FFFFFFF}

and

a+

is implemented as

a{1,0x7FFFFFFF}

which is why you see exactly the same behaviors for curlies and stars.


It's a bug: http://bugs.sun.com/view_bug.do?bug_id=6695369

Pattern.compile() is always supposed to throw an exception if it can't determine the maximum possible length of a lookbehind match.