1、验证邮箱是否合法
/**
* 校验邮箱是否合法
*
* @param email
* @return
*/
public static boolean isEmail(String email) {
String check = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
Pattern regex = Pattern.compile(check);
Matcher matcher = regex.matcher(email);
return matcher.matches();
}
2、验证数据
^-{0,1}\d*\.?\d*$|^-{0,1}\d*\.?\d*%$
总结