I think indexing is the better solution than character
replacement ...
index seems a very good match to your use-case.
... I don't have to think about all possible characters that could
cause issue ...
That's exactly what quotemeta (and its \Q...\E avatar)
does for you: escape all characters that could possibly cause an
issue.
Expanding the regular expression is also extremely useful and
I use it a lot in other applications but thought I had to explicitly
enable it (with eval) rather than explicitly disable it somehow.
I don't understand what this means. Are we still talking about
meta-quotation? Could you give an example of what you're doing
with eval? (Please see Short, Self-Contained, Correct Example.)
Give a man a fish: <%-{-{-{-<
|