Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I have string such a:
"<p>Some text <em>Italic string</em> ... </p><em>Second str</em>"
How can I replace all em tags to i tags ?
In result I need:
"<p>Some text <i>Italic string</i> ... </p><i>Second str</i>"
function replace_em_to_i(content) { var c = content; c =c.replace(/<em>/g,"<i>"); c =c.replace(/<\/em>/g,"</i>"); return c; }
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);
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
function replace_em_to_i(content) { var c = content; c =c.replace(/<em>/g,"<i>"); c =c.replace(/<\/em>/g,"</i>"); return c; }But I am not sure that it is the best solution