我有这样的字符串:
"<p>Some text <em>Italic string</em> ... </p><em>Second str</em>"
如何将所有em标签替换为i标签?
结果我需要:
"<p>Some text <i>Italic string</i> ... </p><i>Second str</i>"
答案 0 :(得分:0)
var replaceTag = "<p>Some text <em>Italic string</em> ... </p><em>Second str</em>";
replaceTag = replaceTag.replace(/<em>/g, "<i>");
replaceTag = replaceTag.replace(/<\/em>/g, "</i>");
console.log(replaceTag);