Joh*_*nks 6 .net javascript regex
任何人都可以帮我提供密码的正则表达式,请使用以下内容.
包括以下至少两项:
小写字母
大写字母
数字
a'特殊字符'(例如£,$,&,#)
正如 Keith Thompson 在评论中所说,我认为单个正则表达式在这里不值得。
\n\n下面的代码将完成您想要的操作,我认为它比单个正则表达式更具可读性、可维护性并且更容易证明正确性:
\n\nstring password = "123abc";\nstring[] regexes = new[]\n {\n "[a-z]", //any lowercase word\n "[A-Z]", //any uppercase word\n @"\\d", //any digit\n @"\\W" //special characters (or just [\xc2\xa3$&#], adding the characters you want)\n };\nbool isValid = regexes.Count(regex => Regex.IsMatch(password, regex)) >= 2; \nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
243 次 |
| 最近记录: |