正则表达式为密码验证(ASP) [英] RegEx for Password Validation (ASP)
问题描述
有人建议可以定期EX pression对符合下列条件验证密码。
Can someone suggest a regular expression for validating a password with the following conditions.
- 密码必须至少12个字符长
- 密码不能以数字开头
- 密码必须有3个出以下4特点:
- 在至少一个大写字母(A-Z)
- 在至少一个小写字母(A-Z)
- 在至少一个数字(0-9)
- 在至少以下符号之一:
连字符( - ),下划线(_),美元($),英镑/哈希(#)
我使用VBScript和传统的ASP。
I'm using vbscript and classic ASP.
在此先感谢,
m0dest0Thanks in advance, m0dest0
推荐答案
当你只有一把锤子吧?
虽然严重,使用正则表达式是不是真的在这里的正确答案。如果您使用正则表达式是死心塌地,那么至少它分解成多个案件,单独评估每个
Seriously though, using a regex is not really the correct answer here. If you're dead set on using regexes, then at least break it up into multiple cases and evaluate each individually.
如果是我的话,我只是写了一组检查每一种情况下简单的功能。例如:一为大/小写,一个数字,一个特殊符号,那么会检查您的所有要求都得到满足时主程序。正如FailedDev上面提到的,一个正则表达式来处理所有这些情况下,将是一个痛苦的写和维护。
If it were me, I'd just write a set of simple functions that check each case. Eg: one for upper/lower case, one for number, one for special symbols, then a main routine that checks that all your requirements are met. As FailedDev mentioned above, a single regex to handle all these cases would be a pain to both write AND maintain..
这篇关于正则表达式为密码验证(ASP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!