import regex string = '100101010001' str_re = '101' print(regex.findall(str_re, string, overlapped=True))
普通的re库匹配,只能匹配一个’101’。