6个回答
展开全部
实现原理,实际上就是输入一个字符串,之后通过正则表达式验证此字符串是否符合邮箱的格式规范,通过以下工具类即可:
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegisterCheck {
/**
* 验证输入的邮箱格式是否符合
* @param email
* @return 是否合法
*/
public static boolean emailFormat(String email)
{
boolean tag = true;
final String pattern1 = "^([a-z0-9A-Z]+[-|//.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?//.)+[a-zA-Z]{2,}$";
final Pattern pattern = Pattern.compile(pattern1);
final Matcher mat = pattern.matcher(email);
if (!mat.find()) {
tag = false;
}
return tag;
}
}
展开全部
正则表达式啊
String reg = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
String email = "sxhsfasdfz@163.com";
boolean isValidaEmail = email.matches(reg);
System.out.println(email.matches(reg));
String reg = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
String email = "sxhsfasdfz@163.com";
boolean isValidaEmail = email.matches(reg);
System.out.println(email.matches(reg));
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
String reg = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
String email = "sxhsfasdfz@163.com";
boolean isValidaEmail = email.matches(reg);
System.out.println(email.matches(reg));
String email = "sxhsfasdfz@163.com";
boolean isValidaEmail = email.matches(reg);
System.out.println(email.matches(reg));
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
String checkPattern = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
Pattern regex = Pattern.compile(checkPattern);
Matcher matcher = regex.matcher(email);
Pattern regex = Pattern.compile(checkPattern);
Matcher matcher = regex.matcher(email);
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2016-01-13
展开全部
面目狰狞
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询