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

2018-04-26 Thread Serhiy Storchaka

Serhiy Storchaka  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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2018-04-26 Thread C. Y. Hollander

New submission from C. Y. Hollander :

The documentation states that match.end([group]) returns "the ind[ex] of the... 
end of the substring matched by group". In fact, it returns [said index] + 1, 
as demonstrated by the example below:

s = 'example'
sre = re.search('le', s)
s[sre.end()]

Incidentally, I don't see the logic of this behaviour, but in any case it 
should be correctly documented.

--
assignee: docs@python
components: Documentation
messages: 315813
nosy: C. Y. Hollander, docs@python
priority: normal
severity: normal
status: open
title: Inaccuracy in https://docs.python.org/3/library/re.html#re.match.end
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com