Original: C # regular expression for checking password complexity
When the user registers and modifies, resets the password, enforces the password to achieve certain complexity, is one of the effective measures to reduce the theft number.
in the code to check the complexity of the password need to use a regular expression, such as requiring the password must contain numbers, lowercase or uppercase, special characters, the number of characters between 8-30, the corresponding regular expression is as follows:
var New Regex (@(? =.*[0-9)) #必须包含数字 (? =.*[a-za-z]) #必须包含小写或大写字母 (? = ([\x21-\x7e]+) [^a-za-z0-9] ) #必须包含特殊符号. {8,30} #至少8个字符, up to 30 characters ", Regexoptions.multiline | Regexoptions.ignorepatternwhitespace);
If the requirement must contain lowercase and uppercase letters, the above (? =.*[a-za-z]) to change to:
(? =.*[a-z]) (? =.*[a-z])
Related Bo Q: How to write a regular expression that matches all special characters on the keyboard
C # Regular expression for checking password complexity