>>> matches = re.findall(f'(?:{p})+', s) >>> matches ['HELLO', 'HELLO', 'HELLOHELLOHELLO', 'HELLOHELLO'] >> max(map(len, matches)) // len(p) 3
>>> matches = re.findall(f'(?:{p})+', s) >>> matches ['HELLO', 'HELLO', 'HELLOHELLOHELLO', 'HELLOHELLO'] >> max(map(len, matches)) // len(p) 3