I have a Python question imagine variable x below. I want to write a regular expression that helps me finds any repeating single digits. Like 1 is not repeated, but 2 is mentioned twice, and 3 is 3 times.
x='1234328732'#a string of digits
re.search(r'(\d+).*\1', x).group(1)
this is what I thought, but this just gives me a return of patterns. The above returns nothing cause there is no repeating patterns. But if
x='1231231234'
it will return 123
But repeating patterns is not what I want. I want repeating digits. So for the first x it should give 2, 3
for the second x it should give 1, 2, 3
This is for learning the RE idea mostly
Thx
may be something like this, using
Counter():