package test;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TestPassword {
public static void main(String args[]){
String password="hahymfghdfg";
Pattern p = Pattern.compile("[A-Z]+");
Pattern q = Pattern.compile("[a-z]+");
Pattern r = Pattern.compile("[0-9]+");
Pattern s = Pattern.compile("\\p{Punct}+");
Matcher m1 = p.matcher(password); //判断是否含有大写字符
Matcher m2= q.matcher(password); //判断是否含有小写字符
Matcher m3 = r.matcher(password);//判断是否含有数字
Matcher m4 = s.matcher(password);//判断是否含有特殊字符
if(m2.find(0)&&( !m4.find(0)) ){
System.out.println("密码符合规则");
}
else{
System.out.println("密码不符合规则");
}
}
}