[issue814253] Grouprefs in lookbehind assertions

Matthew Barnett report at bugs.python.org
Fri Mar 6 04:11:28 CET 2009


Matthew Barnett <python at mrabarnett.plus.com> added the comment:

As part of issue #2636 group references now work in lookbehinds.

However, your example:

    (?<=(...)\1)abc

will fail but:

    (?<=\1(...))abc

will succeed.

Why? Well, in lookbehinds it searches backwards. In the first regex it
sees the group reference before the capture, whereas in the second it
sees the group reference after the capture. (Hope that's clear! :-))

----------
nosy: +mrabarnett

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue814253>
_______________________________________


More information about the Python-bugs-list mailing list