`
Notebookdong
  • 浏览: 120662 次
社区版块
存档分类
最新评论

Java正则表达式判断输入的是否为数字

    博客分类:
  • java
 
阅读更多
public static boolean isNumeric(String str)
    {
          Pattern pattern = Pattern.compile("\\d+\\.?\\d+");
          Matcher isNum = pattern.matcher(str);
          if( !isNum.matches() )
          {
        	  System.out.println("not");
                return false;
          }
          System.out.println("yes");
          return true;
    }

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics