Get all strings matching given RegExp

Alex9968 noname9968 at gmail.com
Thu Apr 3 05:50:52 EDT 2008


Can I get sequence of all strings that can match a given regular 
expression? For example, for expression '(a|b)|(x|y)' it would be ['ax', 
'ay', 'bx', 'by']

It would be useful for example to pass these strings to a search engine 
not supporting RegExp (therefore adding such support to it). A program 
can also let user specify sequence of strings using RegExp (filenames to 
process, etc.). If there are other types of expressions for these 
purposes, please let me know.

I know that for some expressions there would be infinite amount of 
matching strings, but these aren't the cases I'm considering. It'd still 
be possible if string length is limited (there might be large but finite 
number of matching strings).

Thanks



More information about the Python-list mailing list