Enumerating Regular Expressions

Kent Johnson kent at kentsjohnson.com
Tue May 9 22:13:47 CEST 2006

blair.bethwaite at gmail.com wrote:
> Hi all,
> Does anybody know of a module that allows you to enumerate all the
> strings a particular regular expression describes?

Make a generator that yields *all* strings in your chosen alphabet (see 
the monthly threads about permutations and combinations for hints). 
Filter with the regex. Halting is left as an exercise for the reader. 
(Halting when the length reaches a predetermined limit would be one way 
to do it.)


More information about the Python-list mailing list