[Python-Dev] Behavior of matching backreferences
Tim Peters
tim.one@comcast.net
Sun, 23 Jun 2002 15:00:25 -0400
[Tim]
> ..
> There's no such beast as "an optional group". The
>
> ^(a)
>
> part *must* match or the entire regexp fails, period, regardless
> of whether or not backreferences appear later. The question mark
> following doesn't change this requirement. ...
Wow, yesterday's drugs haven't worn off yet <wink>. The details of this
explanation were partly full of beans. Let's consider a different regexp:
^(a)?b\1$
Should that match
b
or not? Python and Perl say "no" today, because \1 refers to a group that
didn't match. Ir remains unclear to me whether Gustavo is saying it should,
but, if he is, that's too big a change, and
^(a?)b\1$
is the intended way to spell it.