跪求邮箱正则式

zhaibing 2008-09-12 10:36:04
如何验证邮箱地址的正确性,不用javascript,要用java代码
如www.java_lover@yahoo.com.cn
www.java_lover@126.com
...全文
237 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhaibing 2008-09-22
  • 打赏
  • 举报
回复
谢谢楼上各位
lybjust 2008-09-12
  • 打赏
  • 举报
回复
我还是觉得要得
sunwei0325 2008-09-12
  • 打赏
  • 举报
回复
坛子里面有个精华贴,里面好多正则,你可以收藏一下,以后方便查找
smsqj 2008-09-12
  • 打赏
  • 举报
回复
Expression: ^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$

Description : Simple email expression. Doesn't allow numbers in the domain name and doesn't allow for top level domains that are less than 2 or more than 3 letters (which is fine until they allow more). Doesn't handle multiple "." in the domain (joe@abc.co.uk).
Matches : joe@aol.com | ssmith@aspalliance.com | a@b.cc
Non-Matches : joe@123aspx.com | joe@web.info | joe@company.co.uk
accomp 2008-09-12
  • 打赏
  • 举报
回复
"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)*$"

我们项目用的 写的比较复杂。看看能不能用上
heliangtai 2008-09-12
  • 打赏
  • 举报
回复

/**
* E-mail正则表达式 如:hlt@qq.com,hlt_hlt@abc.com,hlt_asdf_234@jdlssoft.com.cn
* regEmailStr = "\\w+(@)\\w+(\\.\\w+)(\\.\\w+|)";
*/
String[] email = new String[] { "hello23@abc.com", "hel&lo23",
"hlt@jdlssoft.com.cn", "hlt.hlt@163.com", "hlt_hlt@qq.com",
"11858817@qq.com" };
String regEmailStr = "\\w+(@)\\w+(\\.\\w+)(\\.\\w+|)";
for (int i = 0; i < email.length; i++) {
System.out.println(email[i] + "是email?" + email[i].matches(regEmailStr));
}
rascalboy520 2008-09-12
  • 打赏
  • 举报
回复

/**
* 判断是不是合法Email email Email地址
*/
public static boolean isEmail(String email) {
try {
if (email == null || email.length() < 1 || email.length() > 256) {
return false;
}

String check = "^([0-9a-zA-Z]+[_.0-9a-zA-Z-]+)@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2,3})$";
Pattern regex = Pattern.compile(check);
Matcher matcher = regex.matcher(email);
boolean isMatched = matcher.matches();
if (isMatched) {
return true;
} else {
return false;
}
} catch (RuntimeException e) {
return false;
}
}
junjun1984 2008-09-12
  • 打赏
  • 举报
回复
其實你GOOGLE一下還比發帖子問快呢。GOOGLE一下 哇~好多啊...
jzywh 2008-09-12
  • 打赏
  • 举报
回复
\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
Ami121 2008-09-12
  • 打赏
  • 举报
回复
L匹配Email地址的正则表达式:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
lemon520 2008-09-12
  • 打赏
  • 举报
回复
\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧