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
      -通过对同一组的两个反向引用捕获的单个数字
    • -关闭非捕获组和负前瞻
  • \d{7}
    -7位数字
  • $
    -结束字符串锚定

我觉得如果你能用一些更好/更清晰的描述来重新审视你的实际问题,你会得到更多的回应/答案。现在让我们投票吧。。将在经过精确测试后的一段时间内接受。Thanq Pro Jvdv先生
^(?!.*?(?:012|123|234|345|456|567|678|789|987|876|765|654|543|432|321|210|(\d)\1\1))\d{7}$