The system needs to implement a registration function, need to write a regular expression to check whether a password contains lowercase letters, uppercase letters, numbers, and the password length is 8-20 digits
String password="AA0000fff111";
String regex="^(?:(?=.*[AZ])(?=.*[az])(?=.*[0-9]))[a-zA- Z0-9]{8,20}$";//The expression matches uppercase and lowercase letters and numbers
System.out.println(password.matches(regex));
String regex="^(?:(?=.*[AZ])(?=.*[az])(?=.*[0-9]))[a-zA- Z0-9]{8,20}$";//The expression matches uppercase and lowercase letters and numbers
System.out.println(password.matches(regex));
String regex="^(?:(?=.*[AZ])(?=.*[az])(?=.*[0-9])).{6,12}$";//this The expression matches uppercase and lowercase letters and numbers or uppercase and lowercase letters, numbers and special characters
Reference:
http://blog.csdn.net/zhaoshuliok/article/details/53101994