Python-如何使用正则表达式查找重叠的匹配项?
发布于 2021-02-02 23:21:03
>>> match = re.findall(r'\w\w', 'hello')
>>> print match
['he', 'll']
由于\ w \ w
表示两个字符,因此应使用'he'
和'll
‘。但是,为什么“ el”
和“ lo”
与正则表达式不匹配?
>>> match1 = re.findall(r'el', 'hello')
>>> print match1
['el']
>>>
关注者
0
被浏览
221
1 个回答