private static boolean getEmail(String line){
Pattern p = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
Matcher m = p.matcher(line);
return m.find();
}
Pattern p = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
Matcher m = p.matcher(line);
return m.find();
}
本文介绍了一种使用Java正则表达式来判断字符串是否为合法电子邮件地址的方法。通过Pattern和Matcher类实现了对电子邮件地址格式的有效验证。
318

被折叠的 条评论
为什么被折叠?



