[issue25054] Capturing start of line '^'
Matthew Barnett
report at bugs.python.org
Sat Dec 2 16:29:18 EST 2017
Matthew Barnett <python at mrabarnett.plus.com> added the comment:
The pattern:
\b|:+
will match a word boundary (zero-width) before colons, so if there's a word followed by colons, finditer will find the boundary and then the colons. You _can_ get a zero-width match (ZWM) joined to the start of a nonzero-width match (NWM). That's not really surprising.
If you wanted to avoid a ZWM joined to either end of a NWM, you'd need to keep looking for another match at a position even after you'd already found a match if what you'd found was zero-width. That would also affect re.search and re.match.
For regex on Python 3.7, I'm going with avoiding a ZWM joined to the end of a NWM, unless re's going a different way, in which case I have more work to do to remain compatible! The change I did for Python 3.7+ was trivial.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue25054>
_______________________________________
More information about the Python-bugs-list
mailing list