java正则表达式判断_Java正则表达式判断

/* 判断是否为数字 */     public static boolean isNumeric(String str)     {      if(str == null || str.isEmpty()){       return false;      }         Pattern pattern = Pattern.compile("[0-9]*");         Matcher isNum = pattern.matcher(str);         if (!isNum.matches())         {             return false;         }         return true;     }     /* 判断是否为数字或字母 */     public static boolean isNumOrLetter(String str) {     Pattern pattern = Pattern.compile("^[a-zA-Z0-9]+$");     Matcher isRight = pattern.matcher(str);     if (!isRight.matches())     {         return false;     }     return true; } /* 判断是否有字母 */ public static boolean isLetter(String str) {     Pattern pattern = Pattern.compile(".*[a-zA-Z]+.*");     Matcher islett = pattern.matcher(str);     if (!islett.matches())     {         return false;     }     return true;   } /* 判断是否为+号数字或字母 */  public static boolean isPlusNumOrLetter(String str) {  Pattern pattern = Pattern.compile("^\\+?[a-zA-Z0-9]+$"); ///^\+?[0-9a-zA-Z]+$/  Matcher isRight = pattern.matcher(str);  if (!isRight.matches())  {      return false;  }  return true; }


版权声明:本文为weixin_29103191原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。