正则表达式验证字符串是否为纯数字

/**
* 验证字符串是否为数字
* @param str
* @return
*/
public static boolean isNumeric(String str) {
Pattern pattern = Pattern.compile("[0-9]*");
return pattern.matcher(str.trim()).matches();
}

posted @ 2022-04-02 17:07  教练我想打篮球  阅读(444)  评论(0编辑  收藏  举报