/** * @param line the string to modify * @return the modified string */ public String filter(String line) { initialize(); if (!regexp.matches(line, options)) { return line; } return regexp.substitute( line, substitution.getExpression(getProject()), options); } }
/** * apply regex and substitution on a string * @param string the string to apply filter on * @return the filtered string */ public String filter(String string) { initialize(); if (!regexp.matches(string, options)) { return null; } if (substitution == null) { return string; } return regexp.substitute( string, substitution.getExpression(getProject()), options); } }
/** * Invoke a regular expression (r) on a string (input) using * substitutions (s) for a matching regex. * * @param r a regular expression * @param s a Substitution * @param input the string to do the replacement on * @param options The options for the regular expression * @return the replacement result */ protected String doReplace(RegularExpression r, Substitution s, String input, int options) { String res = input; Regexp regexp = r.getRegexp(getProject()); if (regexp.matches(input, options)) { log("Found match; substituting", Project.MSG_DEBUG); res = regexp.substitute(input, s.getExpression(getProject()), options); } return res; }