zoukankan      html  css  js  c++  java
  • 正则表达式:网页爬虫:从TXT中获取邮箱地址(获取的练习,缺点:一行只能匹配一个)

    1. import java.util.regex.*;  
    2. import java.io.*;  
    3. class L  
    4. {  
    5.     public static void main(String[] args) throws Exception  
    6.     {  
    7.         getMail();  
    8.     }  
    9.     public static void getMail() throws Exception  
    10.     {  
    11.         BufferedReader bufr=new BufferedReader(new FileReader("m.txt"));  
    12.         String line=null;  
    13.         String reg="[a-zA-Z_0-9]+@[a-zA-Z0-9]+(\.[a-zA-Z]+)+";//"\w=@\w+(\.\w+)+";  
    14.         Pattern p=Pattern.compile(reg);  
    15.           
    16.         while((line=bufr.readLine())!=null)  
    17.         {  
    18.             Matcher m=p.matcher(line);  
    19.             while(m.find())  
    20.             {  
    21.                 System.out.println(m.group());  
    22.             }  
    23.         }  
    24.   
    25.     }  
    26. }   
  • 相关阅读:
    注册系统
    android登录界面
    android作业 购物界面
    第六周jsp作业
    JSP第四周
    JSP第二次作业
    JSP第一次作业
    第一周软件测试
    第九次安卓
    购物菜单
  • 原文地址:https://www.cnblogs.com/chengJAVA/p/3246440.html
Copyright © 2011-2022 走看看