[Python-Dev] sre improvements

Andrew Kuchling akuchlin@mems-exchange.org
Wed, 13 Jun 2001 12:39:58 -0400


>For the non-Perl-heads on the list, can you explain what the (?(1)blah)
>operator does?

Conditionals.  From http://www.perl.com/pub/doc/manual/html/pod/perlre.html,
(...)(?(1)A|B) will match 'A' if group 1 matched, and B if it didn't.
I'm not sure how "matched" is defined, as the Perl docs are vague;
judging from the example, it means 'matched something of nonzero
length'.

Perl 5.6 introduced a bunch of new regex features, but I'm not sure
how much we actually *care* about them; they're no doubt useful if
regexes are the only tool you've got and you try to do full parsers
using them, but they're also complicated to explain and will make the
compiler messier.  For example, lookaheads can also go into the
conditional, not just an integer.  (?i) now obeys the scoping from
parens, and you can turn it off with (?-i).

If Gustavo wants to implement these features and /F approves of his
patches, then sure, put them in.  But if either of those conditions
fails, little will be lost.

--amk