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

Categories

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

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

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...