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 w
The set of matching strings is infinite if and only if there is a quantifier (+ or *) in your regexp. Your question doesn't seem to aim at those patterns. I rather believe that the product function from itertools might help here.
You might for instance introduce a special character indicating an arbitrary letter (e.g. an underscore), then build a pattern like this
patt = 'a_c'
and define your alphabet
youralphabet = 'abcde...'
and define a function generating all possible instances like this
def genInstances(patt):
elems = [c if c != '_' else youralphabet for c in patt]
return itertools.product(*elems)
You may then extend this approach to match real regexp by parsing your pattern for \d or [a-zA-Z] or whatever.