I think the subfilter operator and splitting the different elements is key here.
Using the different elements gives you much more flexibility.
In the code the sub variable is the substituted string, where the “text” elements are covered in single quotes … The “debug” line shows the sub-filter string.
It’s a bit trickier as it should be. … I’ll run a new test with the new \function definition from parametrized transclusions preview.
\define search-macro(f, operator, suffix, term)
<$let sub={{{ "[" [<__operator__>] ":" [<__suffix__>] "<__term__>]" +[join[]] }}}>
debug: <$text text=<<sub>>/>
<$list filter="[subfilter<__f__>] +[subfilter<sub>]"/>
</$let>
\end
<<search-macro "[all[tiddlers]!is[system]]" "regexp" "title" "\.[a-zA-Z]{2,4}$">>
----
<<search-macro "[!is[system]limit[250]]" "search" "text" "operator">>