Generating a list of values a regex COULD match in Python

Posted by mlissner on Stack Overflow See other posts from Stack Overflow or by mlissner
Published on 2010-03-17T20:40:24Z Indexed on 2010/03/17 20:41 UTC
Read the original article Hit count: 521

Filed under:
|

I'm trying to use a regex as an input, and from there generate all the possible values that the regex would match.

So, for example, if the regex is "three-letter words starting with a, and ending in c," then the code would generate a list with the values [aac, abc, acc, adc, a1c....].

Is there an easy way to do this? I'm using python.

© Stack Overflow or respective owner

Related posts about python

Related posts about regex