Re: [pcre-dev] Matching file contents as one string using P…

トップ ページ
このメッセージを削除
著者: ph10
日付:  
To: pcunite
CC: pcre-dev
題目: Re: [pcre-dev] Matching file contents as one string using PCRE_DOTALL
On Fri, 10 May 2013, pcunite@??? wrote:

> PCRE does everything I need, thus I'm only looking to increase performance
> and avoid the PCRE_ERROR_MATCHLIMIT I'm getting. I know how to
> increase the config.h value, but I'm thinking of another way.


You can set the match limit at runtime as a parameter to pcre_exec().
You can also discover the minimum requirement via pcretest. In the next
release (8.33) you can set matchlimit in the regex itself.

However, it is always much better to rewrite your regex to avoid the
problem. Avoid nested unlimited repeats if you can; investigate the use
of atomic groups and possessive quantifiers. Get yourself a copy of Jeff
Friedl's book "Mastering Regular Expressions" (3rd Edition, O'Reilly)
which will teach you a lot about optimizing regex (http://regex.info/).

And of course, if you haven't discovered it already, if you can use the
JIT feature of PCRE you get even better performance.

Philip

--
Philip Hazel