Tricky Regular Expression

I need to allow only alphanumeric characters (with upper case) from 0-25 characters and without a lazy all-repeated numerical value.

I have the first part: Regex.IsMatch (tmpResult, "^ [0-9A-Z] {0.25} $"); (which is easy)

111112 - match
AABD333434 - match
55555555 - no match
555 - no match

Can someone help me with this?

+3
source share
2 answers
^(?!(.)\1*$)[0-9A-Z]{0,25}$

Additional (?!(.)\1*$)will reject any lines consisting of a repeating character.

(?!…) - , , …, (.)\1* .

+5

... , , true , , .

true , .

, , , .

0

Source: https://habr.com/ru/post/1771975/


All Articles