当前位置: 首页 > 知识库问答 >
问题:

密码的正则表达式=一个数字,大小写字母和特殊字符,但是!!开始或结束时没有特殊字符

步德宇
2023-03-14
    null

共有1个答案

卫开济
2023-03-14

没那么难:

(                   # Start of group
    (?=.*\d)        #   must contain at least one digit
    (?=.*[A-Z])     #   must contain at least one uppercase character
    (?=.*[a-z])     #   must contain at least one lowercase character
    (?=.*\W)        #   must contain at least one special symbol
    \w
       .            #   match anything with previous condition checking
        {6,18}      #   length is  characters
    \w 
)                   # End of group

一行:

((?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*\W)\w.{6,18}\w)

如果您不喜欢\w,它等于[a-zA-Z0-9_],请将其替换为该组并删除下划线。

 类似资料: