Looking for the regexp for finding all longest digit sequences (starting with length = 5) of the same numbers. E.g.:
Input: \'hgfd 0022222233333 4444 5556555 000
You could use the below regex to match all the longest digit sequences (starting with length = 5),
(\d)\1{4,}
DEMO
>>> s = "hgfd 0022222233333 4444 5556555 0000000" >>> [x.group() for x in re.finditer(r"(\d)\1{4,}", s)] ['222222', '33333', '0000000']
Update:
(\d)(?:\s*\1\s*\1\s*\1)(?:\s*\1)+