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?

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$/

to this:

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

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.

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

Reply via email to