regular expressions questions

Andrew M. Kuchling akuchlin at
Wed Mar 22 23:15:28 CET 2000

"Darrell" <darrell at> writes:
> [Derek Thomson]
> > [ And now, at last, Perl 5.6 allows regexes to refer to other regexes. So
> >now we
> > can uses regexes to parse balanced expressions like matching parenthesis.

Actually, this was an experimental feature in Perl5.005.  Search
the perlre documentation for the (?{ code }) construct.

> >No doubt this will appear in Python's re module before long. ]

This is highly unlikely, because last time around we couldn't come up
with a way to do this that wasn't impressively ugly. See the thread
starting with this July 1998 article:

The general tenor of opinion seemed to be that, if you want to parse
expressions, use a real parser generator, and we certainly have enough
of those for Python.  Adding a feature to regexes for this produces
difficult-to-read code -- you need a pretty intimate knowledge of
exactly how the computer tries matches and then backtracks -- and
makes the matching engine more complicated.  So this feature is almost
certainly not going to be added.  (Elegant patches to add a new
feature, of course, can often reverse theoretical objections.)

A.M. Kuchling
About those crude, hate-filled cartoons in your Lesbian, Gay and Bi issue:
they're meant to subvert and debunk the stereotypical notion that all gay
people are imbued with Wildean wit, right?
    -- C. Doerksen, in a letter to the McGill Daily

More information about the Python-list mailing list