package com.wy.regular;
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 RegularTest {
public static void main(String[] args) {
BufferedReader br = null;
try {
br= new BufferedReader(new FileReader("D:\\xxx\\正则表达式\\2018919.html"));
String line = "";
while ((line = br.readLine()) != null) {
parse(line);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void parse(String line) {
Pattern pattern = Pattern.compile("[\\w[.-]]+@[\\w[.-]]+\\.[\\w]+");
Matcher matcher = pattern.matcher(line);
while (matcher.find()) {
pri(matcher.group());
}
}
public static void pri(Object object){
System.out.println(object);
}
}
结果: