[issue14069] In extensions (?...) the lookbehind assertion cannot choose between the beginning of string and a letter
Ezio Melotti
report at bugs.python.org
Thu Jul 3 18:47:35 CEST 2014
Ezio Melotti added the comment:
I believe this is not a bug.
As the error says a look-behind requires the pattern to have a fixed length.
In re.search(r'(?<=(a|b))(\w+)', 'abc').groups() the two possible patterns in the look behind are "a" and "b", both with length 1.
In re.search(r'(?<=(^|$))(\w+)', 'abc').groups() the two possible patterns in the look behind are "^" and "$", both with length 0.
In re.search(r'(?<=(^|a))(\w+)', 'abc').groups() the two possible patterns in the look behind are "^" and "a", one with length 0 and the other with length 1. This is not allowed and raises an error.
Similarly, in re.search(r'(?<=(ab|a))(\w+)', 'abc').groups() the two patterns have length 2 and 1, and the same error is raised.
Closing as not a bug.
----------
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14069>
_______________________________________
More information about the Python-bugs-list
mailing list