I would not use regex for replacing fixed strings like this but rather substr. That means that this problem of avoiding interpolation etc. just vanishes. As a bonus it should usually be faster too.
🦛
In reply to Re: Elegant way to escape a string in a regex
by hippo
in thread Elegant way to escape a string in a regex
by bliako
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |