-------- Original-Nachricht --------
> Datum: Wed, 9 Mar 2011 09:49:21 +1100
> Von: Erik de Castro Lopo <mle+to...@mega-nerd.com>
> An: postfix-users@postfix.org
> Betreff: Re: regular expressions  was:  Kernel Oops

> Wietse Venema wrote:
> 
> > If you must match a very large numbers of patterns, you need an
> > implementation that transforms N patterns into one deterministic
> > automaton. This can match 1 pattern in the same time as N patterns.
> > Once the automaton is built (which takes some time) it is blindingly
> > fast. An example of such an implementation is flex.
> 
> Is there a limit the the pattern length in the pcre tables?
> 
I think there is one (if memory does not fool me then it is somewhere around 
1000 characters). But I am not 100% sure.


> If not, it would be possible to convert this (3 only, but could be
> hundreds or even thousands):
> 
>    /^([0-9]{1,3}\.){4}\.dsl\.dynamic\.eranet\.pl$/
>    /^([0-9]{1,3}\.){4}\.dynamic\.snap\.net\.nz$/
>    /^([0-9]{1,3}\.){4}\.nat\.umts\.dynamic\.eranet\.pl$/
> 
Are you sure the above is correct? You have there a double dot and I think that 
is not correct.


> to this:
> 
>   
> /^([0-9]{1,3}\.){4}\.(dsl\.dynamic\.eranet\.pl|dynamic\.snap\.net\.nz|nat\.umts\.dynamic\.eranet\.pl)$/
> 
Or even shorter:
/^([0-9]{1,3}\.){4}((dsl\.dynamic|nat\.umts)\.dynamic\.eranet\.pl|dynamic\.snap\.net\.nz)$/

Maybe using if/endif conditions like Stan Hoeppner has done on his pcre map 
could speedup things even more? -> http://www.hardwarefreak.com/fqrdns.pcre


> and that should reject "1.1.1.1.not-found" in 1/3 the time of the
> three original regexes while also matching quicker than the original.
> 
> Obviously, a conversion from the first three to the optimised version
> has to be done mechanistically to avoid errors.
> 
Well... if the source is already buggy (double dot issue) then automating that 
transformation is not going to help you much.



> Cheers,
> Erik
> -- 
// Steve


> ----------------------------------------------------------------------
> Erik de Castro Lopo
> http://www.mega-nerd.com/

-- 
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit 
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl

Reply via email to