Javascript Regular Expressions Escape HTML Tag
let pieceOfHtml = "<p>This is a <span>paragraph</span></p>"; console.log(pieceOfHtml);//w w w . ja v a 2 s . c o m pieceOfHtml = pieceOfHtml.replace(/</g,"<"); pieceOfHtml = pieceOfHtml.replace(/>/g,">"); console.log(pieceOfHtml);