It appears that PHP's preg_match
has a 3276 character limit for matching repeating characters in some cases.
i.e.
^(.|\s){0,3276}$
works, but ^(.|\s){0,3277}$
does not.
It doesn't seem to always apply, as /^(.){0,3277}$/
works.
I can't find this mentioned anywhere in PHP's documentation or the bug tracker. The number 3276 seems a bit of an odd boundary, the only thing I can think of is that it's approximately 1/10th of 32767, which is the limit for a signed 16-bit integer.
preg_last_error()
returns 0.
I've reproduced the issue on http://www.phpliveregex.com/ as well as my local system and the webserver.
EDIT: Looks like we're getting "Warning: preg_match(): Compilation failed: regular expression is too large at offset 16" out of the code, so it appears to be the same issue as PHP preg_match_all limit.
However, the regex itself isn't very large... Does PHP do some kind of expansion when you have repeating groups that's making it too large?