final Pattern pattern = Pattern.compile(regex); final Matcher matcher = pattern.matcher(srcContent); final StringBuffer sb = new StringBuffer(); if (matcher.find()) { matcher.appendReplacement(sb,replaceContent); } return sb.toString(); 原文链接:https://www.f2er.com/regex/361977.html