Replaces the first instance of a matched string in a given input.