On Apr 3, 4:50 am, Alex9968 <[EMAIL PROTECTED]> wrote: > 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'] >
Actually, this regex will only match 'a', 'b', 'x', or 'y' (assuming you meant to bracket it with leading '^' and trailing '$'). To get the set you listed, you would need to invert '(a|b)(x|y)'. The thread that Gabriel Genellina referenced includes a link to a pyparsing regex inverter (http://pyparsing-public.wikispaces.com/space/ showimage/invRegex.py), which I used to test your regex - I've added both regexes in the test cases of that script. Some of the other test cases include regexes for all US time zones, and all chemical symbols. -- Paul -- http://mail.python.org/mailman/listinfo/python-list