如何找到與regexp重疊的匹配?>>> match = re.findall(r'\w\w', 'hello')>>> print match['he', 'll']因為\w意味著兩個字符,所以需要“he”和“ll”。但是為什么‘el’和‘lo’不匹配判決嗎?>>> match1 = re.findall(r'el', 'hello')>>> print match1['el']>>>
3 回答

瀟瀟雨雨
TA貢獻1833條經驗 獲得超4個贊
>>> import regex as re>>> match = re.findall(r'\w\w', 'hello', overlapped=True)>>> print match['he', 'el', 'll', 'lo']
添加回答
舉報
0/150
提交
取消