title: PHP preg_match length 3276 limit
body: <p>It appears that PHP's <code>preg_match</code> has a 3276 character limit for matching repeating characters in some cases.</p>
  
  <p>i.e.</p>
  
  <p><code>^(.|\s){0,3276}$</code> works, but <code>^(.|\s){0,3277}$</code> does not.</p>
  
  <p>It doesn't seem to always apply, as <code>/^(.){0,3277}$/</code> works.</p>
  
  <p>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.</p>
  
  <p><code>preg_last_error()</code> returns 0.</p>
  
  <p>I've reproduced the issue on <a href="http://www.phpliveregex.com/" rel="nofollow noreferrer">http://www.phpliveregex.com/</a> as well as my local system and the webserver.</p>
  
  <p>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 <a href="https://stackoverflow.com/questions/8268624/php-preg-match-all-limit">PHP preg_match_all limit</a>.</p>
  
  <p>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?</p>