棘手的正则表达

Ois*_*era 3 c# regex repeat

我只需要允许0-25个字符长度的字母数字字符(带大写),并且不允许任何延迟的全重复数值.

我有第一部分:Regex.IsMatch(tmpResult,"^ [0-9A-Z] {0,25} $"); (这很简单)

111112 - 对阵
AABD333434 - 对阵
55555555 - 对不对
555 - 不匹配

有人可以帮我这个吗?

ken*_*ytm 5

^(?!(.)\1*$)[0-9A-Z]{0,25}$
Run Code Online (Sandbox Code Playgroud)

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.