[Go] C # regular expression to check password complexity

Source: Internet
Author: User

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 regex = new Regex (@ "=.*[0-9])                     #必须包含数字 (? =.*[a-za-z])                  #必须包含小写或大写字母 (? = ([\x21-\x7e]+) [^a-za-z0-9])  # Special symbols must be included. {8,30}                         #至少8个字符, up to 30 characters ", Regexoptions.multiline | Regexoptions.ignorepatternwhitespace);

If the requirement must contain lowercase, uppercase letters, the above (? =.*[a-za-z]) should be changed to:

(? =.*[a-z]) (? =.*[a-z])

Related Bo Q: How to write a regular expression that matches all special characters on the keyboard

[Go] C # regular expression to check password complexity

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.