String str="1010";
String regEx = "^(\\d{8}|\\d{11})$"; //8位或11位数字
String regEx2 = "^[0-9_]+$";//纯数字
Pattern pattern = Pattern.compile(regEx);
Matcher matcher = pattern.matcher(str);
boolean rs = matcher.matches();
System.out.println(rs);
判断匹配是否是8位或11位数字
最新推荐文章于 2024-02-19 16:43:38 发布