使用简单正则表达式对获取数据(也就是密码)进行检验,符合规定就返回true,不符合就返回false。
评论区里面有我使用时的方法,想要的自取。
import java.lang.*;
public class PasswordCheck {
public static final String testpassword = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[a-zA-Z0-9\\W_]{8,20}$";
public static boolean check(String password) {
if (password.matches(testpassword)) {
return true;
}
return false;
}
}
/**
* @apiDescription This is the Description.
* It is multiline capable.
* 此文件用于对于密码规格的验证,密码因不小于8位而且有至少大小写字母或者特殊字符
* Last line of Description.
*/