在需要我使用pattern属性设置密码字段的项目上工作。确实没有做很多正则表达式的东西,并且想知道是否有人可以帮忙。
该字段的要求如下:
现在,到目前为止,我有以下内容:
[^(password)].(?=.*[0-9])?=.*[a-zA-Z]).{8,12}
这行不通。我们可以得到它,从而使其他所有工作都可以进行,除了要匹配的密码字符串。
在此先感谢,安迪
编辑:我们现在使用的方法(嵌套在下面的注释中)是:^(?!.*(P|p)(A|a)(S|s)(S|s)(W|w)(O|o)(R|r)(D|d)).(?=.*\d)(?=.*[a-zA-Z]).{8,12}$
谢谢您的帮助
此正则表达式应适用于以下工作:
^(?!.*password)(?=.*\d)(?=.*[A-Z])(?=.*[a-z]).{8,12}$
它将匹配:
^ // from the beginning of the input
(?!.*password) // negative lookbehind whether the text contains password
(?=.*\d+) // positive lookahead for at least one digit
(?=.*[A-Z]+) // positive lookahead for at least one uppercase letter
(?=.*[a-z]+) // positive lookahead for at least one lowercase letter
.{8,12} // length of the input is between 8 and 12 characters
$
链接到phpliveregex
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句