使用java验证邮箱的格式是否符合要求的代码:
1 public boolean isEmail(final String searchPhrase){
2 final String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
3 final Pattern regex = Pattern.compile(check);
4 final Matcher matcher = regex.matcher(searchPhrase);
5 return matcher.matches();
6 }