private static final String MAIL_REGEX = "^([a-z0-9A-Z]+[_|-|\\.]?)+[a-z0-9A-Z]@"
+"([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
private static final String PUSH_TOKEN_REGEX = "^([a-z0-9A-Z]{64})$";
private static final int MAIL_LENGTH = 98;
/**
* Description:邮件格式校验
*
* @author qiaowang
* @param mail
* @return boolean
*/
public static boolean checkMail(String mail) {
if (mail == null) {
throw new NullPointerException("mail is null");
}
if(mail.length() > MAIL_LENGTH){
return Boolean.FALSE;
}
Pattern regex = Pattern.compile(MAIL_REGEX);
Matcher matcher = regex.matcher(mail);
return matcher.matches();
}
public static boolean checkPushToken(String pushToken) {
if (pushToken == null) {
throw new NullPointerException("push token is null");
}
Pattern regex = Pattern.compile(PUSH_TOKEN_REGEX);
Matcher matcher = regex.matcher(pushToken);
return matcher.matches();
}
邮件格式校验及字符长度校验
猜你喜欢
转载自wangqiaowqo.iteye.com/blog/1946434
今日推荐
周排行