简体   繁体   English

JS正则表达式格式和列表验证

[英]JS regex format & list validation

I have to validate that an input is just digits and its value is not 'blacklisted'. 我必须验证输入只是数字,其值不是“黑名单”。 The expression I made is the following: 我做的表达如下:

(?=[0-9]{3})(?=(?!^(111)|^(222)|^(333)|^(123)|^(321)\b)\b\w+)

I've tested it on a regex validator and works perfectly! 我在正则表达式验证器上进行了测试,效果非常好!

BUT because of framework limitations my regex is surrounded by and additional ^...& delimiters making it match with any input. 但由于框架限制,我的正则表达式被其他^ ...&分隔符包围,使其与任何输入匹配。

Im trying to came up with a new regex that works when surrounded by the delimiters, but Im having trouble figuring it out. 我试图想出一个新的正则表达式,当它被分隔符包围时起作用,但我很难搞清楚它。

Does somebody have any idea on how to achieve this? 有人知道如何实现这个目标吗?

What about using 怎么样使用

    ^(?!111|222|333|123|321)(\d{3,})$
//  ^                                 if this is added by the framework omit
//   ^^^^^^^^^^^^^^^^^^^^^^^          the first 3 numbers must not match any of these groups
//                           ^^       digit
//                              ^^^^  at least 3 times
//                                  ^ followed by end of string. Again if added by framework omit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM