convert list of strings to set of regexes; convert list of strings to trie

Klaus Neuner klaus_neuner82 at yahoo.de
Tue Jul 20 03:42:42 EDT 2004


François Pinard <pinard at iro.umontreal.ca> wrote in message news:<mailman.577.1090250197.5135.python-list at python.org>...

> By the way, the regexp compiler in Python library
> already turns, at least logically, `(blaa)|(blab)|(raaa)|(rabb)' into
> `(bla(a|b))|(ra(aa|bb))' -- disregarding of course how groups are being
> saved by parentheses.  So, you may also peek in this direction.

What do you mean exactly by "logically"? That Python translates 

(1) (blaa)|(blab)|(raaa)|(rabb)

to something (logically equivalent to)

(2) (bla(a|b))|(ra(aa|bb))

before matching it? Does this mean that (1) (taken as normal regex) is always
exactly as fast as (2) (taken as normal regex)?

Klaus



More information about the Python-list mailing list