Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
824 views
in Technique[技术] by (71.8m points)

regex - PHP preg_match_all limit

I'm using preg_match_all for very long pattern.

when run the code, i got this error :

Warning: preg_match_all(): Compilation failed: regular expression is too large at offset 707830

After searching, I got the solution, so I should increase value of pcre.backtrack_limit and pcre.recursion_limit in php.ini

But after I increase the value and restart my apache, it still got the same problem. My PHP verison is 5.3.8

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

That error is not about the performance of the regex, it's about the regex itself. Changing the pcre.backtrack_limit and pcre.recursion_limit isn't going to have any effect because the regex never gets a chance to run. The problem is that the regex is too big, and the solution is to make the regex smaller--much, much smaller.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...