I agree with CountZero, it sounds like you want index() to get the starting position of the substring, then you can use substr() as an lvalue to assign your replacement string.
However this sounds like what regular expressions were designed for, so either quotemeta() or the following may be a better fit:
s/\Q$pattern\E/$replacement/gIn reply to Re: "exact" pattern matching
by spacebat
in thread "exact" pattern matching
by my_nihilist
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |