/**
      * 
      * 判断是否是邮箱
      * 
      * @param mobile 手机号码
      * @return boolean
      */
     public static boolean isEmail(String email)
     {
         if (email==null||email.equals(""))
         {
             return false;
         }
         
         String check = "^(\\w+((-\\w+)|(.\\w+))*)+\\w+((-\\w+)|(.\\w+))*@([0-9a-z]+(\\.[a-z]{2,})+)$";
         Pattern regex = Pattern.compile(check);
         Matcher matcher = regex.matcher(email);
         
         return matcher.matches();
     }
     
     
     /**
      * 
      * 判断字符串是否是手机号码
      * 
      * @param mobile 字符串
      * @return boolean
      */
     public static boolean isMobile(String mobile)
     {
         boolean isMobile = Boolean.FALSE;
         try
         {
             Long.parseLong(mobile);
             isMobile = Boolean.TRUE;
         }
         catch (NumberFormatException nfe)
         {
             isMobile = Boolean.FALSE;
         }
         
         if (mobile.startsWith("1") && 11 == mobile.length())
         {
             isMobile = Boolean.TRUE;
         }
         else
         {
             isMobile = Boolean.FALSE;
         }
         
         return isMobile;
     }

 

版权声明:本文为yangzhenlong原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/yzlpersonal/p/5108876.html