[Python-Dev] sre improvements
Jeff Epler
jepler@inetnebr.com
Wed, 13 Jun 2001 11:09:58 -0500
On Wed, Jun 13, 2001 at 11:03:58AM -0500, Skip Montanaro wrote:
>
> Gustavo> I'd like, for example, to see the (?(1)blah) operator,
> Gustavo> available in perl, working.
>
> Gustavo,
>
> For the non-Perl-heads on the list, can you explain what the (?(1)blah)
> operator does?
from perlre(1):
(?(condition)yes-pattern)
Conditional expression. (condition) should be
either an integer in parentheses (which is valid
if the corresponding pair of parentheses
matched), or lookahead/lookbehind/evaluate zero-
width assertion.
Say,
m{ ( \( )?
[^()]+
(?(1) \) )
}x
matches a chunk of non-parentheses, possibly
included in parentheses themselves.
Jeff