Regex 避免相等连续数的正则表达式
我试图建立以下标准Regex 避免相等连续数的正则表达式,regex,Regex,我试图建立以下标准 The following captures should not be allowed: 1) Null fields 2) Field captured as “000000” 3) Field captured with consecutive numbers “123456” 4) Field captured with equal numbers “111111” 5) input
The following captures should not be allowed:
1) Null fields
2) Field captured as “000000”
3) Field captured with consecutive numbers “123456”
4) Field captured with equal numbers “111111”
5) input length is 7 digits not less or more
使用的正则表达式=^(?([0-9]{7}))。$
谢谢,
Prasad聊天后,我们完成了以下规则,其中输入:
- 必须正好是7位数字
- 不能包含任何三个相同的重复字符,例如:“111”
- 不能包含任何三个连续数字(正向/反向),例如:“123”或“321”
因此,似乎以下内容确实勾选了您的方框:
^(?!.*?(?:012|123|234|345|456|567|678|789|987|876|765|654|543|432|321|210|(\d)\1\1))\d{7}$
在线查看
-启动字符串锚定^
-打开反向前瞻:(?!
-0个以上字符(惰性)*?
-打开非捕获组:(?:
-在您的输入中任何地方都可以避免使用这些选项012 | 123 | 234 | 345 | 456 | 567 | 678 | 789 | 987 | 876 | 765 | 654 | 543 | 432 | 321 | 210
-或:|
-通过对同一组的两个反向引用捕获的单个数字(\d)\1\1
-关闭非捕获组和负前瞻)
-7位数字\d{7}
-结束字符串锚定$
^(?!.*?(?:012|123|234|345|456|567|678|789|987|876|765|654|543|432|321|210|(\d)\1\1))\d{7}$