Long repeat with regex solution in Clear category for Long Repeat by new_hoschi
def long_repeat(line: str) -> int:
if not line: return 0 ## catch empty strings
patterns=re.finditer(r'(.)\1*',line) ## list nonintersecting patterns with any element repeating itself (or appearing exaclty once)
return max([len(i.group()) for i in patterns]) ## i.group() (or i.group(0)) returns the whole pattern with repeating character. Here we find the longest of these patterns.
March 26, 2020