import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Demo
{
public static void main(String[] args) throws Exception
{ //匹配文本文件中的邮件
BufferedReader bufr=new BufferedReader(new FileReader("D:/Test/youday.txt"));
String line=null;
String regex="\\w+[\\w._]*@[\\w.]+\\.[\\w.]*\\w+"; //正则表达式
Pattern p=Pattern.compile(regex);
while((line=bufr.readLine())!=null)
{
Matcher m=p.matcher(line);
while(m.find())
{
System.out.println(m.group());
}
}
}
}
转载于:https://my.oschina.net/foreverun/blog/96234