// f : Matcher -> S sS regexReplace(S s, S pat, O f) { ret regexReplace(regexpMatcher(pat, s), f); } sS regexReplace(S s, S pat, S replacement) { ret regexpReplace_direct(s, pat, replacement); } sS regexReplace(Matcher m, O f) { new StringBuffer buf; while (m.find()) m.appendReplacement(buf, m.quoteReplacement(str(callF(f, m)))); m.appendTail(buf); ret str(buf); } sS regexReplace(S s, S pat, IF1 f) { ret regexReplace(s, pat, (O) f); }