Home >Backend Development >PHP Tutorial >Preg_match long string matching failure problem solution_PHP tutorial

Preg_match long string matching failure problem solution_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:48:401169browse

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478408.htmlTechArticleI was checking a problem today. It failed to extract content from a string using regular expressions. I repeatedly checked the string and regular expressions. , no problem. I wrote a small script to test again, and there is no problem. Return to...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn