import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class EmailSpider
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
try
{
BufferedReader bufferedReader = new BufferedReader(new FileReader("E:\\123.htm"));
String line = "";
try
{
while((line = bufferedReader.readLine())!= null)
{
parse(line);
}
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void parse(String line)
{
Pattern pattern = Pattern.compile("[\\w[.-]]+@[\\w[.-]+\\.[\\w]]+");
Matcher matcher = pattern.matcher(line);
while(matcher.find()){
System.out.println(matcher.group());
}
}
}
JAVA学习正则表达式提取email
最新推荐文章于 2024-09-08 13:15:25 发布