Generating text from a regular expression

Paul McGuire ptmcg at austin.rr.com
Wed Mar 31 11:23:48 EDT 2010


On Mar 31, 5:49 am, Nathan Harmston <iwanttobeabad... at googlemail.com>
wrote:
> Hi everyone,
>
> I have a slightly complicated/medium sized regular expression and I
> want to generate all possible words that it can match (to compare
> performance of regex against an acora based matcher).

The pyparsing wiki Examples page includes this regex inverter:
http://pyparsing.wikispaces.com/file/view/invRegex.py

>From the module header:
# Supports:
# - {n} and {m,n} repetition, but not unbounded + or * repetition
# - ? optional elements
# - [] character ranges
# - () grouping
# - | alternation

-- Paul



More information about the Python-list mailing list