var str = "a222b333c"; var matcher = Pattern.compile("\\d+").matcher(str); while(matcher.find()) { //输出匹配到数据 System.out.println(matcher.group()); //拿到所有匹配项都被替换过的str var replacedStr = matcher.replaceAll("数字"); //拿到首个匹配项被替换过的str var firstReplacedStr = matcher.replaceFirst("数字"); } //拿到被正规匹配到数据分隔的字符串 var items = Pattern.compile("\\d+").split("a1b2c3d45ef");