PHP中preg_match函数正则匹配的字符串长度问题,phppreg_match
PHP中preg_match函数正则匹配的字符串长度问题,phppreg_match
项目中,用preg_match正则提取目标内容,死活有问题,代码测得死去活来。
后来怀疑PHP 的preg_match有字符串长度限制,果然,发现“pcre.backtrack_limit ”的值默认只设了100000。
解决办法:ini_set('pcre.backtrack_limit', 999999999);
注:这个参数在php 5.2.0版本之后可用。
另外说说关于:pcre.recursion_limit
pcre.recursion_limit是PCRE的递归限制,这个项如果设很大的值,会消耗所有进程的可用堆栈,最后导致PHP崩溃。
也可以通过修改配置来限制:ini_set('pcre.recursion_limit', 99999);
实际项目应用中,最好也对内存进行限定设置:ini_set('memory_limit', '64M'); , 这样就比较稳妥妥嘎。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor
