// This pattern, used in the function below, is compiled and saved here for efficiency. static final Pattern pNeverFail = Pattern.compile("^"); // Return the target text associated with a matcher object. public static String text(Matcher m) { // Remember these items so that we can restore them later. Integer regionStart = m.regionStart(); Integer regionEnd = m.regionEnd(); Pattern pattern = m.pattern(); // Fetch the string the only way the class allows. String text = m.usePattern(pNeverFail).replaceFirst(""); // Put back what we changed (or might have changed). m.usePattern(pattern).region(regionStart, regionEnd); // Return the text return text; } ----------------------------------------------------------------------------- Copyright 1997-2024 Jeffrey Friedl