How to replace curly quotation marks in a string using Javascript?

You might have to (or prefer to) use Unicode escapes:

var goodQuotes = badQuotes.replace(/[\u2018\u2019]/g, "'");

That’s for funny single quotes; the codes for double quotes are 201C and 201D.

edit — thus to completely replace all the fancy quotes:

var goodQuotes = badQuotes
  .replace(/[\u2018\u2019]/g, "'")
  .replace(/[\u201C\u201D]/g, '"');

Leave a Comment