用正则表达式提取出文本文件中所有的email
[url=http://vsp.iteye.com/blog/1704613]从网页中提取email[/url]
BufferedReader bufr = new BufferedReader(new FileReader("d://email.txt"));
String line = null;
String regex = "[a-zA-Z0-9_-]+@\\w+\\.[a-z]+(\\.[a-z]+)?"; // email正则
Pattern p = Pattern.compile(regex);
while((line = bufr.readLine()) != null) {
Matcher m = p.matcher(line);
while(m.find()) {
System.out.println(m.group()); // 输出匹配的email
}
}
[url=http://vsp.iteye.com/blog/1704613]从网页中提取email[/url]