Solve the problem of long string matching failure in preg_match. I am checking a problem today. I failed to extract the content from the string using regular expressions. I checked the strings and regular expressions repeatedly. I wrote a small script for testing, and there is no problem. I went back to today and checked a problem. I failed to extract the content from the string using regular expressions. I checked the strings and regular expressions repeatedly. I wrote a small script for testing. there is no problem. I went back to the code for debugging and failed again.
The string is relatively long, so it is suspected that preg_match also has a string length limit. sure enough!
Both preg_match and preg_match_all have this situation.
Solution:
1. ini_set ('pcre. backtrack_limit ', 1000000); // The default value is only 100000.
2. modify the pcre. backtrack_limit parameter of php. ini to support larger strings. Add configuration: pcre. backtrack_limit =-1
Excerpt from encoding
Bytes. I wrote a small script for testing. there is no problem. go back...