正则表达式 排除子串名称(job corps) 包括至少1个大写字母、1个小写字母、1个数字和1个除“@”以外的符号

Regular Expression To exclude sub-string name(job corps) Includes at least 1 upper case letter, 1 lower case letter, 1 number and 1 symbol except "@"

正则表达式排除子串名称(job corps)
包括至少 1 个大写字母、1 个小写字母、1 个数字和 1 个符号,除了“@”

我写了如下内容:

^((?!job corps).)(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!#$%^&*]).*$

我用上面的正则表达式测试过,对特殊字符不起作用。

任何人都可以指导这个..

如果我很了解你的要求,你可以使用这个模式:

^(?![^a-z]*$|[^A-Z]*$|[^0-9]*$|[^!#$%^&*]*$|.*?job corps)[^@]*$

如果您只想允许来自 [a-zA-Z0-9^#$%&*] 的字符,请将模式更改为:

^(?![^a-z]*$|[^A-Z]*$|[^0-9]*$|[^!#$%^&*]*$|.*?job corps)[a-zA-Z0-9^#$%&*]*$

详情:

^ # start of the string
(?! # not followed by any of these cases
    [^a-z]*$  # non lowercase letters until the end
  |
    [^A-Z]*$  # non uppercase letters until the end
  |
    [^0-9]*$
  |
    [^!#$%^&*]*$
  |
    .*?job corps # any characters and "job corps"
)
[^@]* # characters that are not a @
$     # end of the string

demo

注意:您可以将范围#$%&写成#-&来赢得一个字符。

stribizhev,你的回答是正确的

^(?!.工作团)(?=.[0-9])(?=.[a-z])(?=. [A-Z])(?=.[!#$%^&])(?!.@).$

可以验证下面url中的表达式:

http://www.freeformatter.com/regex-tester.html