regex = new RegExp(`(^|\\s|[.,])${original_escaped}($|\\s|[.,])`, 'gi'); if (v.match(regex)) { v = v.replace(regex, `$1${replacements[original]}$2`); matchFound = true; }