Let's change a little your source string:
x = "jhg**11111**jjhgj**22222**klhhkjh33333jhjkh44444"
The regex should be:
pat = r'(.)\1{4}'
Here you have a capturing group (a single char) and a backreference
to it (4 times), so totally the same char must occur 5 times.
One variant to print the result, although less intuitive is:
res = re.findall(pat, x)
print(res)
But the above code prints:
['1', '2', '3', '4']
i.e. a list, where each position is only the capturing group (in our case
the first char), not the whole match.
So I propose also the second variant, with finditer and
printing both start position and the whole match:
for match in re.finditer(pat, x):
print('{:2d}: {}'.format(match.start(), match.group()))
For the above data the result is:
5: 11111
19: 22222
33: 33333
43: 44444
Countercould be your friend.Counterby itself doesn't tell you anything about consecutive runs of identical characters.Counteris not useful here because the characters have to be adjacent,itertools.groupbycould be used thoughnidentical characters, no "identify identicaln-long sequences within the string".