package utils; import java.util.regex.Pattern; public class ValidationUtil { public static boolean isValidEmail(String email) { String emailRegex = "^[A-Za-z0-9+_.-]+@(.+)$"; return Pattern.compile(emailRegex).matcher(email).matches(); } public static boolean isValidPassword(String password) { // 6-10位,必须包含大小写字母和数字 if (password.length() < 6 || password.length() > 10) { return false; } boolean hasUpperCase = false; boolean hasLowerCase = false; boolean hasDigit = false; for (char c : password.toCharArray()) { if (Character.isUpperCase(c)) hasUpperCase = true; if (Character.isLowerCase(c)) hasLowerCase = true; if (Character.isDigit(c)) hasDigit = true; } return hasUpperCase && hasLowerCase && hasDigit; } public static boolean isNumeric(String str) { try { Double.parseDouble(str); return true; } catch (NumberFormatException e) { return false; } } }