rule = r'abc' # r prefix, the rule you want to check in a given string print re.findall(rule,"aaaaabcaaaaaabcaa") # return ['abc', 'abc']