用于限制密码输入的正则表达式 [英] regular expression to constraint the password input
本文介绍了用于限制密码输入的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
约束密码输入的正则表达式是什么,以便用户必须输入最小长度为7且包含至少一个非字母数字字符的密码
谢谢所有人
hello
what is the regular expression to constraint the password input such that the user must enter a password which minimum length is 7 and containing at least one non-alphanumeric char
thanks all
推荐答案
很复杂-但可能:
It''s complex - but possible:
^.*(?=.{8,10})(?=.*[!"£
%^& *()_] )(?=.* [a-zA-Z]).*
%^&*()_])(?=.*[a-zA-Z]).*
''和]''之间的字符是允许的特殊字符坦率地说,我不会为此使用正则表达式-我会在代码中这样做,它更易于维护.
The characters between the ''['' and '']'' are the permitted special characters. To be honest, I wouldn''t use a regex for this - I''d do it in code, it''s a lot more maintainable.
这篇关于用于限制密码输入的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文