Issue 14461: In re's positive lookbehind assertion documentation match() cannot match (original) (raw)

Created on 2012-04-01 08:12 by py.user, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg157265 - (view) Author: py.user (py.user) * Date: 2012-04-01 08:11
http://docs.python.org/py3k/library/re.html "Note that patterns which start with positive lookbehind assertions will never match at the beginning of the string being searched; you will most likely want to use the search() function rather than the match() function:" >>> re.match(r'(?<=^)abc', 'abc').group() 'abc' >>> re.match(r'(?<=\b)abc', 'abc').group() 'abc' >>> re.match(r'(?<=\A)abc', 'abc').group() 'abc' >>> re.match(r'(?<=\A)abc', 'abc', re.DEBUG).group() assert -1 at at_beginning_string literal 97 literal 98 literal 99 'abc' >>> in some cases match() can match
msg159571 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-04-29 04:35
New changeset 7c262962b681 by Ezio Melotti in branch '2.7': #14461: fix wording. http://hg.python.org/cpython/rev/7c262962b681 New changeset 7f35da912739 by Ezio Melotti in branch '3.2': #14461: fix wording. http://hg.python.org/cpython/rev/7f35da912739 New changeset d68b4885fc0f by Ezio Melotti in branch 'default': #14461: merge with 3.2. http://hg.python.org/cpython/rev/d68b4885fc0f
msg159572 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-04-29 04:40
Technically you are correct, however using zero-width classes inside a lookbehind doesn't make much sense, because the result would be equivalent even without lookbehind. I replaced 'never' with 'not', because usually it will not match, except in these corner cases that can IMHO be ignored.
History
Date User Action Args
2022-04-11 14:57:28 admin set github: 58666
2012-04-29 04:40:16 ezio.melotti set status: open -> closedassignee: docs@python -> ezio.melottiversions: + Python 2.7, Python 3.3messages: + type: enhancementresolution: fixedstage: resolved
2012-04-29 04:35:38 python-dev set nosy: + python-devmessages: +
2012-04-01 08:12:00 py.user create