$ 0 0 Replacing part of a string with another string is straight forward, but what if you have to replace last occurrence of a character or string with another string. Here is the fastest way to do this.