// f takes variable without $ sign. if it returns null, variable is kept sS replaceDollarVars_dyn(S s, IF1 f) { if (f == null) ret s; ret regexpReplaceIC(s, "\\$(\\w+)", matcher -> { S var = matcher.group(1); S val = f.get(var); ret val == null ? matcher.group() : str(val); }); }