代码如下:
public class VerificationUtils {
/**
* 判断手机号格式是否正确
* @param phone
* @return
*/
public static boolean checkPhone(String phone){
return phone != null && phone.matches("1[3-9]\\d{9}");
}
/**
* 判断邮箱格式是否正确
* @param email
* @return
*/
public static boolean checkEmail(String email){
return email != null && email.matches("\\w{1,30}@[a-zA-Z0-9]{2,20}(\\.[a-zA-Z0-9]{2,20}){1,2}");
}
/**
* 判断电话号格式是否正确
* @param tel
* @return
*/
public static boolean checkTel(String tel){
return tel != null && tel.matches("0\\d{2,6}-?\\d{5,20}");
}
/**
* 判断QQ号格式是否正确
* @param qq
* @return
*/
public static boolean checkQQ(String qq){
return qq != null && qq.matches("\\d{6,20}");
}
}