/**
      * 
      * 判断是否是邮箱
      * 
      * @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;
     }

 

相关文章:

  • 2021-12-28
  • 2021-12-03
  • 2021-12-28
  • 2021-07-30
  • 2021-07-19
  • 2021-12-28
  • 2021-09-23
猜你喜欢
  • 2021-07-07
  • 2021-10-31
  • 2021-08-17
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案