[docs] [issue33368] Inaccuracy in https://docs.python.org/3/library/re.html#re.match.end

Serhiy Storchaka report at bugs.python.org
Thu Apr 26 16:03:03 EDT 2018


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

It returns not the index of the last character of the substring, but the index of the end of the substring, i.e. the position past the last character of the substring.

Try s[:sre.end()] and s[sre.end():].

s[sre.begin()] gives you the part of s before the matched substring, s[sre.begin():sre.end()] gives you the matched substring itself (the same as sre.group()) and s[sre.end():] gives you the part of s after the matched substring.

----------
nosy: +serhiy.storchaka
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33368>
_______________________________________


More information about the docs mailing list