It looks like PHP preg_match has a 3276 character limit for matching duplicate characters in some cases.
i.e.
^(.|\s){0,3276}$ works, but ^(.|\s){0,3277}$ does not work.
This does not seem to always apply, since it works /^(.){0,3277}$/ .
I cannot find this anywhere in the PHP documentation or the error debugger. 3276 seems like a bit of a weird border, the only thing I can think of is that it's about 1/10 of 32767, which is the limit for a signed 16-bit integer.
preg_last_error() returns 0.
I reproduced the problem http://www.phpliveregex.com/ as well as my local system and web server.
EDIT: it looks like we are getting a "Warning: preg_match (): compilation failed: the regular expression is too large at an offset of 16 inches from the code, so this seems to be the same problem as the preg_match_all PHP prefix .
However, the regular expression itself is not very large ... Is PHP some kind of extension when you repeat groups that make it too big?
php preg-match
Stu
source share