正则表达式匹配列表中的字符,除非存在另一个列表中的字符

我正在尝试构建一个正则表达式来验证我的应用程序中的密码。


这是 PCRE (php)。


我的正则表达式到目前为止看起来像这样


/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*\(\)_\+\-\=\[\]\{\}\|'])(?=.*[^\\\/])(?=.{8,20})/

我的标准如下


minimum length:            8

maximum length:            20

require special character: true

require uppercase:         true

require lowercase:         true

require number:            true

special character set:     !@#$%^&*()_+-=[]{}|'

excluded character set:    \/

一切正常,但排除的字符集除外。这个想法是密码不能包含该列表中指定的任何字符。


谢谢您的帮助


MMTTMM
浏览 90回答 1
1回答

千万里不及你

使用/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*()_\-+=[\]{}|'])[^\/]{8,20}$/见证明选择:/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*()_\-+=[\]{}|'])[A-Za-z0-9!@#$%^&*()_+\-=[\]{}|']{8,20}$/看另一个证明minimum length:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 8&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <= {8,20}maximum length:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 20&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<= {8,20}require special character: true&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<= (?=.*[!@#$%^&*()_\-+=[\]{}|'])require uppercase:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;true&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<= (?=.*[A-Z])require lowercase:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;true&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<= (?=.*[a-z])require number:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; true&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<= (?=.*[0-9])special character set:&nbsp; &nbsp; &nbsp;!@#$%^&*()_+-=[]{}|' <= [^\/]excluded character set:&nbsp; &nbsp; \/&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<= [^\/]
打开App,查看更多内容
随时随地看视频慕课网APP