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