Use regular expressions to increase the complexity and security of user passwords

Source: Internet
Author: User

 Public classPasswordutil {StaticString regex_number = "[\\p{digit}]+";//Digital    StaticString regex_lower = "[\\p{lower}]+";//Regular expression password: lowercase letter    StaticString regex_upper = "[\\p{upper}]+";//Uppercase Letters    StaticString Regex_char = "[\\p{punct}]+";//Punctuation         Public Static BooleanMatchespass (String user_password) {if(user_password==NULL){            return false; }                if(User_password.length () <8){            return false; }                if(User_password.matches (regex_number)||user_password.matches (regex_upper)||user_password.matches (regex_lower)||user_password.matches (Regex_char)) {              //return "Registration failed, password does not meet the requirements, uppercase + lowercase + number + characters (at least 2 kinds)";             return false; }          return true; }         Public Static voidMain (string[] args) {String a="!! ADDD ";    System.out.println (Matchespass (a)); }    }

Use regular expressions to increase the complexity and security of user passwords

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.