minimalist regular expression

Paul McGuire ptmcg at austin.rr.com
Fri Aug 26 09:13:04 EDT 2005


Google for "optimized regexp" returns:
http://laurent.riesterer.free.fr/regexp/make-regexp.html
http://search.cpan.org/~dankogai/Regexp-Optimizer-0.15/

There are several more links, but all appear to be written in languages
other than Python.  Perhaps you could port one of them.

It also seems that a similar thread came up here recently, at least in
the special form of converting a list of words to a single regexp.  In
general, this seems to be a difficult problem, not only to implement,
but to test.  At least the conversion of a list of words to a single
regexp is easily tested against the input set, although as some of the
other clever posters have noted, it is possible to create a regexp that
is *too* matchable.

-- Paul




More information about the Python-list mailing list