Replaces all instances of a matched string in a given input.