How to write Python Regular Expression find repeating digits in a number?



The following code using Python regex to find the repeating digits in given string

Example

import re
result = re.search(r'(\d)\1{3}','54222267890' )
print result.group()

Output

This gives the output

2222

Advertisements