Extended functionality of the replace() method.