in reply to "exact" pattern matching
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/g
|
|---|