Spontaneous thought (...at 4 a.m so possibly gobbledigook)
Replacing something is a pretty complex action. Still one that is doable using a wikitext macro consisting of various subfilters that split out the first part of the string, remove the out-string, append the chaing-in, append the rest of original, etc. (I did this in
cherrypicker and probably
@ttention)
Sooo... if the aim is to make a general operator... how about a "macro operator" that takes the filter run output at that point and uses it as input to a user made wikitext macro. The output is then passed on to the rest of the run. E.g:
\define foo() $input$bar (or maybe even just $$, i.e $$bar here)
[tag[grok]macro[foo]suffix[bar]] (gives some true result)
This would solve your need and just in general be a super powerful operator, AFAICT.
<:-)