regex - How to make sure that certain digits in a number are not the same -


i have couple of number strings following:

0000000 0000011 0000012 

i want validate pattern this:

aaaaabc 

where a, b , c different digits. in example, 0000012 should matched.

my regex far (\d)\1\1\1\1\d\d, doesn't make sure digits different. need do?

i think want

(\d)\1{4}(?!\1)(\d)(?!\1|\2)\d 

explanation:

(\d)       # match digit, capture in group 1 \1{4}      # match same digit before 4 times (?!\1)     # assert next character not same digit before (\d)       # match digit, capture in group 2 (?!\1|\2)  # assert next character different both previous digits \d         # match digit. 

see on regex101.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -