Making regex suck less

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


Bengt Richter wrote:

> I agree about new syntax, but I wouldn't mind having a re.help(regexp) 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)
in
  range (97, 122)
max_repeat 0 65535
  in
    category category_digit

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

</F>





More information about the Python-list mailing list