正则表达式--抓取email地址

前端之家收集整理的这篇文章主要介绍了正则表达式--抓取email地址前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MainClass {

    private static BufferedReader bufferedReader;

    public static void main(String[] args) {
        try {
            bufferedReader = new BufferedReader(new FileReader("D:\\11111.html"));
            String line = "";
            while ((line=bufferedReader.readLine())!=null) {
                parseline(line);
            }
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        }
    }

    private static void parseline(String line) {
        Pattern pattern = Pattern.compile("([\\w[.-]]+@[\\w[.-]]+\\.)(com|net|cn)");
        Matcher matcher = pattern.matcher(line);
        while (matcher.find()) {
            System.out.println(matcher.group());
        }
    }
}
zhanghao163mail@163.com
....
....
原文链接:https://www.f2er.com/regex/359191.html

猜你在找的正则表达式相关文章