public static String replaceAllRegion(Matcher m, String replacement) { Integer start = m.regionStart(); Integer end = m.regionEnd(); m.reset().region(start, end); // Reset the matcher, but then restore the region StringBuffer result = new StringBuffer(); // We'll build the updated copy here while (m.find()) m.appendReplacement(result, replacement); m.appendTail(result); return result.toString(); // Convert to a String and return } ----------------------------------------------------------------------------- Copyright 1997-2024 Jeffrey Friedl