Mine
public text v1 · immutablemacro replace(s, find, replacement) {
// replace arg2 with arg3 in arg1; store result in arg4
// NOTE: ARG2 and ARG3 *must* be exactly one byte!
Repl_dst=; // clear any old value
for (Repl_field=1; ${LEN(${Repl_dst})} <= ${LEN(${s})}; Repl_field=${Repl_field} + 1) {
Repl_new=${CUT(s,${find},${Repl_field})};
Repl_dst=${Repl_dst}${replacement}${Repl_new};
};
Repl_var=REPLACED;
if ("${ARG4}" != "")
Repl_var=${ARG4};
${Repl_var}=${Repl_dst:${LEN(${replacement})}};
};