Making regex suck less

Fredrik Lundh fredrik at
Wed Sep 4 03:14:08 EDT 2002

Bengt Richter wrote:

> I agree about new syntax, but I wouldn't mind having a function
> for interactive use that would just explain in 'English' what the regexp expression
> stands for.

you can ask SRE to dump the internal parse tree
to stdout:

>>> sre.compile("[a-z]\d*", sre.DEBUG)
  range (97, 122)
max_repeat 0 65535
    category category_digit

turning this into 'English' is left as an exercise etc.


More information about the Python-list mailing list