String str = "xxx第47297章33"; String regex = "\\d*"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(str); while (m.find()) { if (!"".equals(m.group())) System.out.println("come here:" + m.group()); }
打印结果为
come here:47297 come here:33
String str = "xxx第47297章33"; String regex = "\\d*"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(str); while (m.find()) { if (!"".equals(m.group())) System.out.println("come here:" + m.group()); }
打印结果为
come here:47297 come here:33