Try:
str = str.replace(/[""]/g, '"');
str = str.replace(/[‘’]/g,"'");
or to do it in one statement:
str = str.replace(/[""]/g, '"').replace(/[‘’]/g,"'");
I'm not a JavaScript expert, but in many languages strings are immutable - string "replacement" methods actually just return the new string instead of modifying the string in place. (Bizarrely enough, the few JavaScript string tutorials I've just looked up don't state a string's immutability - something I'd expect to be in the first or second paragraph of a C# or Java string tutorial.)
Jon Skeet
- 1.5m
- 894
- 9.3k
- 9.3k