I have a javascript function that replaces strings that match against a profanity library with symbols. eg. damn is transformed into @#$%&!
However, this replace is non-discriminating, and will transform partial matches as well. eg. classic is transformed into cl@#$%&!ic
I'm very new to TS/JS and Regex and would like some help understanding this function's arguments and how to modify them for only exact matches.
this.replace(new RegExp(str1.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g, "\\$&"), (ignore ? "gi" : "g")), (typeof (str2) == "string") ? str2.replace(/\$/g, "$$$$") : str2);