Oliver Nassar

Regular Expression was returning NULL (limit related)

February 14, 2013

I restarted my server yesterday and started running into strange behaviour with my regular expresions. All of a sudden, ones that I was running against an html document started returning null. I was dumbfounded. But what I realized was my php.ini file got reset to an earlier version with a very low value for the property pcre.backtrack_limit.

It was being set to 1000, despite the PHP default of 1000000. I simply had to increase it.

Worth noting, as mentioned in a comment on the configuration defaults page is that the actual number of calls may be limited to much fewer based on how PCRE handles character encoding itself.

I've tested this quite high, and my server seemed to be able to handle it quite well.