You would need to replace via php, and check in the php whether the href is the same as the current url.
Not very easy, as there are different ways to format the same url. With or without the domain, with or without an ending slash, etc.
So can be done, but requires you to do some custom php coding in the replacement.