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.

Leave a Comment