正则表达式排除子字符串名称(作业队)包括至少1个大写字母,1个小写字母,1个数字和1个符号,除了" @"

时间:2015-11-06 09:16:37

标签: asp.net regex qregularexpression

正则表达式要排除子字符串名称(作业队)
包括至少1个大写字母,1个小写字母,1个数字和1个符号,除了" @"

我写了类似下面的内容:

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

我使用上面的正则表达式测试过,不适用于特殊字符。

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

2 个答案:

答案 0 :(得分:0)

如果我理解你的要求,你可以使用这种模式:

No stash found

如果您只想允许来自^(?![^a-z]*$|[^A-Z]*$|[^0-9]*$|[^!#$%^&*]*$|.*?job corps)[^@]*$ 的字符,请将模式更改为:

[a-zA-Z0-9^#$%&*]

细节:

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

demo

注意:您可以像^ # 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 一样编写范围#$%&来赢得角色。

答案 1 :(得分:0)

stribizhev,你的回答是正确的

^(?!。工作队)(?=。 [0-9])(?=。 [az])(?=。 [AZ] )(= ??![#$%^&安培; <!/ EM>])( @) $

可以验证以下网址中的表达式:

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