Tim Peters added the comment:

BTW, note that the idea "successful lookaround assertions match an empty 
string" isn't just a figure of speech:  it's the literal truth, and - indeed - 
is key to understanding what happens here.  You can see this by adding some 
capturing groups around the assertions.  Like so:

m = re.search("((?<=a))((?<=a))((?<=a))((?<=a))b", "xab")

Then

[m.span(i) for i in range(1, 5)]

produces

[(2, 2), (2, 2), (2, 2), (2, 2)]

That is, each assertion matched (the same) empty string immediately preceding 
"b" in the target string.

This makes perfect sense - although it may not be useful.  So I think this 
report should be closed with "so if it bothers you, don't do it" ;-)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14460>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to