比如 :"abbaca",如何匹配出来 bb ,并将其删除? 我想的是用re.sub()函数,但是匹配规则写不出来。
import re s = 'abbaca' s = re.sub(r"(\w)\1+","",s) print(s)