Hello, I’d like to have something like:
foo(rs::String, t::String) = replace(rs, r"(aa|bb)" => s"\1$(t)")
Note the replacement string uses both a substitution (\1
) and an interpolation ($t
). This does not seem to be allowed and I’m not sure what my options are short of doing a match and writing the replacement myself manually.
Ideally the function would do:
foo("aac", "dd") == "aaddc"
foo("bbe", "ff") == "bbffe"
Am I missing something? is there a natural way to do this? thanks!