You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
TestSystem/src/main/java/com/mathapp/utils/ValidationUtils.java

29 lines
792 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.mathapp.utils;
import java.util.regex.Pattern;
public class ValidationUtils {
// 邮箱正则表达式
private static final String EMAIL_REGEX =
"^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$";
// 密码正则表达式6-10位至少一个数字一个小写字母一个大写字母
private static final String PASSWORD_REGEX =
"^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{6,10}$";
public static boolean isValidEmail(String email) {
if (email == null) {
return false;
}
return Pattern.matches(EMAIL_REGEX, email);
}
public static boolean isValidPassword(String password) {
if (password == null) {
return false;
}
return Pattern.matches(PASSWORD_REGEX, password);
}
}