Home > php教程 > php手册 > body text

preg_match长字符串匹配失败问题解决

WBOY
Release: 2016-06-13 10:47:27
Original
1041 people have browsed it

今天在查一个问题,用正则从字符串中提取内容失败,反复检查字符串和正则表达式,都没有问题。又写了小脚本测试,还没有问题,回到代码中调试,又失败了。
字符串比较长,因此怀疑是不是preg_match也有字符串长度限制,果然!
preg_match、preg_match_all都会有这种情况。
 
解决方法:
1、ini_set(‘pcre.backtrack_limit’, 1000000); //默认的只有100000
2、修改php.ini 的pcre.backtrack_limit参数,使之支持更大的字符串。加入配置:pcre.backtrack_limit=-1
 

摘自 编码者说

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!