import java.util.regex.*;
import java.io.*;
class L
{
public static void main(String[] args) throws Exception
{
getMail();
}
public static void getMail() throws Exception
{
BufferedReader bufr=new BufferedReader(new FileReader("m.txt"));
String line=null;
String reg="[a-zA-Z_0-9]+@[a-zA-Z0-9]+(\\.[a-zA-Z]+)+";//"\\w=@\\w+(\\.\\w+)+";
Pattern p=Pattern.compile(reg);
while((line=bufr.readLine())!=null)
{
Matcher m=p.matcher(line);
while(m.find())
{
System.out.println(m.group());
}
}
}
}
正则表达式:网页爬虫:从TXT中获取邮箱地址(获取的练习)
最新推荐文章于 2024-08-21 00:06:52 发布