[issue42448] re.findall have different match result against re.search or re.sub
赵豪杰
report at bugs.python.org
Mon Nov 23 14:30:57 EST 2020
New submission from 赵豪杰 <1292756898 at qq.com>:
```
>>> import re
>>> text = '121212 and 121212'
>>> pattern = '(12)+'
>>> print(re.findall(pattern, text))
['12', '12']
>>>
>>>
>>> print(re.search(pattern, text))
<re.Match object; span=(0, 6), match='121212'>
>>>
>>>
>>> print(re.sub(pattern, '', text))
and
# The re.findall have different search result against re.search or re.sub
# re.findall 和 re.search 、 re.sub 的匹配结果不相同
```
With same pattern and string, the re.findall is supposed to have same match with re.search, but it didn't.
This result is from python3.8.5
----------
components: Regular Expressions
messages: 381689
nosy: HaujetZhao, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: re.findall have different match result against re.search or re.sub
type: behavior
versions: Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42448>
_______________________________________
More information about the Python-bugs-list
mailing list