function replaceStrColor(inputStr, color) { let temp = inputStr.replace(/[“"]((?!["“]).)+["”]/gi, function (item) { return "<span style='color:" + color + "'>" + item + "</span>"; }); return temp; } var content = '内容“aaaa”更改为内容“bbbbb”'; console.info(replaceStrColor(content, "#EE0000")) // 输出结果:内容<span style='color:#EE0000'>“aaaa”</span>更改为内容<span style='color:#EE0000'>“bbbbb”</span>