隨筆-47  評論-14  文章-0  trackbacks-0
          import java.io.*;
          import java.util.regex.*;

          public class test{
           public static void main(String[] args){
            try{
             String s = "";
             while(!s.equals("q")){
              System.out.print("input:");
              DataInputStream in = new DataInputStream(new BufferedInputStream(System.in));
              s = in.readLine();
              System.out.println("your input is :"+s);
              String check = "^([a-z0-9A-Z]+[-|\\._]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
              Pattern regex = Pattern.compile(check);
                          Matcher matcher = regex.matcher(s);
                          boolean isMatched = matcher.matches();
                          if(isMatched){
                           System.out.println("it's a email");
                       }else{
                        System.out.println("it's not a email");
                       } 
              
             }
                  }catch(Exception e){
                   System.out.println("error"+e.getMessage());
               }
           }         
          }

          posted on 2005-04-16 14:02 Stephen 閱讀(731) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 许昌市| 彭阳县| 丹凤县| 辉南县| 东丽区| 县级市| 呼和浩特市| 太仓市| 日喀则市| 峨边| 元朗区| 乌兰县| 威远县| 巴中市| 田东县| 五大连池市| 枣庄市| 勃利县| 屯门区| 上饶县| 长春市| 德令哈市| 南丹县| 门头沟区| 贞丰县| 肃南| 隆安县| 寿阳县| 曲阜市| 康定县| 贵南县| 寻乌县| 兴安县| 台山市| 观塘区| 定结县| 融水| 榆中县| 金塔县| 宜宾县| 全州县|