I was checking a problem today, and it failed to extract content from a string using regular expressions. I repeatedly checked the string and regular expressions, but there was no problem. I wrote a small script to test again, and there was no problem. I went back to the code to debug, and it failed again.
The string is relatively long, so I wonder if preg_match also has a string length limit, and sure enough!
This will happen with preg_match and preg_match_all.
Solution:
1. ini_set(‘pcre.backtrack_limit’, 1000000); //The default is only 100000
2. Modify the pcre.backtrack_limit parameter of php.ini to support larger strings. Add configuration: pcre.backtrack_limit=-1
Excerpted from What Coders Say