查找正则表达式的唯一电子邮件地址
import java.io.IOException;//NowJava.com - 时 代 Java 提 供 import java.util.Iterator; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static void main(String args[]) throws IOException { TreeSet<String> ts = new <String>TreeSet(); String str = "abc@email.com"; Pattern p = Pattern.compile("[A-Za-z_.]{1,}@[a-z.]*[a-z]{1,3}"); Matcher m = p.matcher(str); /*N o w J a v a . c o m 提供*/ if (m.find()) { ts.add(m.group()); } Iterator<String> it = ts.iterator(); while (it.hasNext()) { System.out.print(it.next());