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

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