This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: re.finditer behaviour in re.MULTILINE mode fails to match first 7 characters
Type: behavior Stage: resolved
Components: Regular Expressions Versions: Python 3.8, Python 3.7, Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, mrabarnett, tdawes
Priority: normal Keywords:

Created on 2018-10-02 21:29 by tdawes, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg326911 - (view) Author: Tom Dawes (tdawes) Date: 2018-10-02 21:29
re.finditer appears to fail to match within the first 7 characters in a string when re.MULTILINE is used:

>>> REGEX = re.compile("y")
>>> [list(m.start() for m in REGEX.finditer("{}y".format("x"*i), re.MULTILINE)) for i in range(10)]
[[], [], [], [], [], [], [], [], [8], [9]]

Without re.MULTILINE, this works fine:

>>> [list(m.start() for m in REGEX.finditer("{}y".format("x"*i))) for i in range(10)]
[[0], [1], [2], [3], [4], [5], [6], [7], [8], [9]]

Passing re.MULTILINE to re.compile doesn't seem to have any effect.
msg326912 - (view) Author: Tom Dawes (tdawes) Date: 2018-10-02 21:32
Please ignore, re.finditer and REGEX.finditer aren't the same. I was passing re.MULTILINE (= 8) to endPos.
History
Date User Action Args
2022-04-11 14:59:06adminsetgithub: 79054
2018-10-02 21:32:07tdawessetstatus: open -> closed
resolution: not a bug
messages: + msg326912

stage: resolved
2018-10-02 21:29:14tdawescreate