繁星淼淼
如果您希望密码中包含字母,特殊字符和数字(至少8位数字),那么使用此代码,即可正常运行public static boolean Password_Validation(String password) { if(password.length()>=8) { Pattern letter = Pattern.compile("[a-zA-z]"); Pattern digit = Pattern.compile("[0-9]"); Pattern special = Pattern.compile ("[!@#$%&*()_+=|<>?{}\\[\\]~-]"); //Pattern eight = Pattern.compile (".{8}"); Matcher hasLetter = letter.matcher(password); Matcher hasDigit = digit.matcher(password); Matcher hasSpecial = special.matcher(password); return hasLetter.find() && hasDigit.find() && hasSpecial.find(); } else return false;}