Android验证邮箱:
/** * 验证邮箱格式是否正确 */ public boolean emailValidation(String email) { String regex = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"; return email.matches(regex); }
或者:
private boolean isValidEmail(String mail) {
Pattern pattern = Pattern
.compile("^[A-Za-z0-9][\\w\\._]*[a-zA-Z0-9]+@[A-Za-z0-9-_]+\\.([A-Za-z]{2,4})");
Matcher mc = pattern.matcher(mail);
return mc.matches();
}