I need to allow only alphanumeric characters (with uppercase) from 0-25 chars length and no lazy all-repetition numeric value.
I've got the first part: Regex.IsMatch(tmpResult, "^[0-9A-Z]{0,25}$"); (that's easy)
111112 - match
AABD333434 - match
55555555 - no match
555 - no match
Could anyone please help me with this?
^(?!(.)\1*$)[0-9A-Z]{0,25}$
The extra (?!(.)\1*$) will reject any strings that is composed of repeating same character.
The (?!…) is a negative lookahead that will cause the primary regex fail if the … is matched, and the (.)\1* will match a string of repeating characters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With