gpt4 book ai didi

正则密码问题

转载 作者:行者123 更新时间:2023-12-04 04:36:58 24 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Regexp Java for password validation

(17 个回答)


7年前关闭。




在一个项目中工作,它要求我使用模式属性有一个密码字段。
并没有真正做很多正则表达式的东西,想知道是否有人可以帮忙。

该领域的要求如下:

  • 不能包含单词“密码”
  • 长度必须为 8-12
  • 必须有 1 个大写
  • 必须有 1 个小写
  • 必须有 1 位数字

  • 现在,到目前为止,我有以下几点:
    [^(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

    关于正则密码问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19585988/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com