import re matches = [match.group() for match in re.finditer(r"(.)\1{2,}", "AAAbbcDDDEDGGGG") if len(match.group()) == 3] print(matches)