我想做这样的事情:
s = s.replace(/(”)/g, '"'); // need to replace with double quotes
s = s.replace(/(“)/g, '"'); // need to replace with double quotes
s = s.replace(/(’)/g, "'"); // need to replace with single quotes
但对我来说这是行不通的。我尝试了所有方法。
最佳答案
您可以在替换中使用 Unicode 值:
s = s.replace(/\u201C|\u201D/g, '"'); // for “ or ”
s = s.replace(/\u2019/g, "'"); // for ’
关于javascript - 如何用双引号替换“&ldquo?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12574075/