Adding removeAndReplaceChars function that takes a matched substring and
makes changes on it.