正则表达式允许至少一个特殊字符,一个大写,一个小写(以任何顺序) [英] regex to allow atleast one special character, one uppercase, one lowercase(in any order)
本文介绍了正则表达式允许至少一个特殊字符,一个大写,一个小写(以任何顺序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能帮我用一个正则表达式来允许至少一个特殊字符,一个大写,一个小写.
Can anyone help me with a regex to allow atleast one special character, one uppercase, one lowercase.
这是我目前所拥有的:
^.*(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$
但它似乎只能按照特殊字符"、大写"、小写"的顺序匹配字符.
but it seems to match the characters only in the order "special character", "uppercase", "lowercase".
非常感谢任何帮助
推荐答案
你的正则表达式
^.*(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$
实际上应该可以正常工作,但是您可以通过删除第一个 .*
使其更好:
should actually work just fine, but you can make it a lot better by removing the first .*
:
^(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$
将匹配至少包含一个小写和一个大写 ASCII 字符以及至少一个来自 @#$%^&+=
集合的至少 8 个字符的字符串(在任何顺序).
will match any string of at least 8 characters that contains at least one lowercase and one uppercase ASCII character and also at least one character from the set @#$%^&+=
(in any order).
这篇关于正则表达式允许至少一个特殊字符,一个大写,一个小写(以任何顺序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文