[New-bugs-announce] [issue14461] In re's positive lookbehind assertion documentation match() cannot match

py.user report at bugs.python.org
Sun Apr 1 10:12:00 CEST 2012


New submission from py.user <port139 at yandex.ru>:

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

----------
assignee: docs at python
components: Documentation, Regular Expressions
messages: 157265
nosy: docs at python, ezio.melotti, mrabarnett, py.user
priority: normal
severity: normal
status: open
title: In re's positive lookbehind assertion documentation match() cannot match
versions: Python 3.2

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


More information about the New-bugs-announce mailing list