outlook有一种email地址格式采用逗号分隔开字段扩展名叫CSV 例如 姓名称谓单位名称部门职务邮政地址邮政编码电话传真统一编码其他电话单位其他移动电话呼机主页电子邮件备注 下面写个程序打开csv文件每行读取只用第一个逗号前的字符串作为姓名email地址匹配格式取第一个(位置无关)粗陋程序如下 private static final String repmail =([\\w]+[@]{}((\\w)+[]){}(\\w)+); private static final String repname =+?; Pattern mailPattern = pile(repmail ); Pattern namePattern = pile(repname); File file = new File(testCSV); FileInputStream is = new FileInputStream(file); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String input = null; ArrayList list = new ArrayList(); while((input = brreadLine())!=null){ Matcher matchermail = mailPatternmatcher(input); Matcher matchername = namePatternmatcher(input); String[] card = new String[]; if(matchernamefind()){ card[] = matchernamegroup()replaceAll(\); } if(matchermailfind()){ card[] = matchermailgroup(); } if(card[]==null || card[]equals() || card[]==null || card[]equals()){ continue; } listadd(card); }//输出for(int i=;i Systemoutprintln(((String[])listget(i))[] + : + ((String[])listget(i))[]); } |