Enumerating Regular Expressions

Kent Johnson kent at kentsjohnson.com
Tue May 9 16:13:47 EDT 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.)

Kent



More information about the Python-list mailing list