正则查找一篇文章中的email地址
来源:互联网 发布:java gc算法 编辑:程序博客网 时间:2024/05/05 15:46
查找一片文章中的所有邮箱地址:
public class EmailSpiler { public static void main(String[] args) { try { BufferedReader buf = new BufferedReader(new FileReader("C:\\Users\\Administrator\\Desktop\\dfsafd.html")); String line =""; while((line=buf.readLine())!=null){ parse(line); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }/** * 邮箱的正则 * @param line */ private static void parse(String line) { Pattern p = Pattern.compile("(\\w)+(\\.\\w+)*@((\\w)+(\\.\\w{2,3}){1,3})"); Matcher m = p.matcher(line); while(m.find()){ System.out.println(m.group()); } }}
这篇是看你写的代码有多少注释 多少空行 以及实际代码量
public class CodeCounter { //正常 static long normalLine=0; //注释行 static long commentLine =0; //空行 static long whiteLine=0; public static void main(String[] args) { File f = new File("F:\\新建文件夹 (2)\\shiro02\\src\\main\\java\\com\\wskj\\app\\util\\"); File[] codeFiles = f.listFiles(); for (File child : codeFiles) { if (child.getName().matches(".*\\.java$")) { parse(child); } } System.out.println("正常代码行数:normalLine="+normalLine); System.out.println("注释行数:commentLine="+commentLine); System.out.println("空白行数:whiteLine="+whiteLine); } private static void parse(File f) { BufferedReader br = null; boolean comment = false; try { br = new BufferedReader(new FileReader(f)); String line=""; while((line = br.readLine())!=null){ line = replaceBlank(line); if(line.matches("^[\\s&&[^\\n]]*$")){ whiteLine ++; }else if(line.startsWith("/*") && line.endsWith("*/")){ commentLine++; }else if(line.startsWith("/*") && !line.endsWith("*/")){ commentLine++; comment = true; }else if(true == comment){ commentLine++; if(line.endsWith("*/")){ comment=false; } }else if(line.startsWith("//")){ commentLine++; }else{ normalLine++; } } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally{ if(br!=null){ try { br.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } /** * 替换所有的空格 制表 换行 为 "" * @param str * @return */ public static String replaceBlank(String str) { String dest = ""; if (str!=null) { Pattern p = Pattern.compile("\\s*|\t|\r|\n"); Matcher m = p.matcher(str); dest = m.replaceAll(""); } return dest; }}
1 0
- 正则查找一篇文章中的email地址
- java 正则 抓取文件中的email地址
- 查找文本中的网址或email地址[原创哈]
- 利用正则表达式提取html中的的Email地址
- 使用正则表达式抓取网页中的email地址
- 利用正则表达式揪出网页中的email地址
- 基本的Email地址正则
- 正则表达式验证Email地址
- 正则表达式--抓取email地址
- 匹配Email地址的正则表达式
- 利用正则表达式抓取Email地址
- JavaScript 检查 email 地址的正则表达式
- 电话、地址、Email等常用正则表达式
- 正则表达式应用:匹配email地址
- 匹配 Email 地址的正则表达式
- 正则匹配电话号码,网址链接,Email地址
- 匹配Email地址的一个正则
- 电话、地址、Email等常用正则表达式
- 对称加密 des desede aes
- oracle----例外
- okhttp或者retrofit实现网络缓存504错误原因
- js实现搜索历史记录功能
- mysql计划任务(轮询执行脚本)
- 正则查找一篇文章中的email地址
- 欢迎大家关注我的微信公众号
- 游戏开发中网络通讯协议对比
- oracle------视图
- ubuntu 下识别android设备
- Eclipse里自动导入相应包的类名的快捷键
- java web 工程名后面设置访问默认url
- Base64 编码方式
- Android中EditText如何限制为手机号码