题目描述
密码要求
1、长度超过8位
2.包括大小写字母、数字、其他符号,以上4种至少三种
3.不能有相同长度超过2的子串重复 说明:长度超过2的子串
输入描述
一组或多组长度超过2的字符串。每组占一行
输出描述
如果符合要求输出:OK,否则输出NG
public class AdminPassword {
//String类中有一个String.matches() ,这个方法主要是
// 返回是否匹配指定的字符串,如果匹配则为true,否则为false;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNextLine()) {
String input = sc.nextLine();
int counter = 0;//作用是验证要求2,每当密码中有一个类型时就+1
if (input.matches(".*\\d.*")){
counter++;
}
if (input.matches(".*[a-z].*")){
counter++;
}
if (input.matches(".*[A-Z].*")){