// 按指定模式在字符串查找
String line = "8784ssR#";
String pattern = "(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@#$%^&*_.]).{8,}";
// 創建 Pattern 對象
Pattern r = Pattern.compile(pattern);
// 現在創建 matcher 對象
Matcher m = r.matcher(line);
boolean matches = m.matches();
System.out.println(matches);
