public static void main(String[] args) {
//8 表示每个数字的长度
Pattern pattern = Pattern.compile("([0-9]{8}[,]?)+");
String bigStr1 = "20170841,1";
String bigStr2 = "20170841,20170842";
Matcher isNum1 = pattern.matcher(bigStr1); // matcher是全匹配
//匹配返回true,否则返回false
System.out.println(isNum1.matches());
Matcher isNum2 = pattern.matcher(bigStr2); // matcher是全匹配
System.out.println(isNum2.matches());
}
判断是否为纯数字拼接而成的字符串
最新推荐文章于 2024-04-10 11:24:07 发布