[issue16870] re fails to match ^ when start index is specified ?

Ned Deily report at bugs.python.org
Sat Jan 5 11:22:02 CET 2013


Ned Deily added the comment:

To expand a bit, rather than multiple calls to search, you can use the start and end methods of the match object to determine where the string (without the '^' anchor) matches.  For example:

r = re.compile("abc")
s = "0123abcxyz"
match = r.search(s)
if match:
    print(match.start(), match.end())

----------

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


More information about the Python-bugs-list mailing list