Escape HTML quotation - Node.js String

Node.js examples for String:HTML String

Description

Escape HTML quotation

Demo Code


function escapeHtml(unsafe) {
    return unsafe
         .replace(/&/g, "&")
         .replace(/</g, "&lt;")
         .replace(/>/g, "&gt;")
         .replace(/"/g, "&quot;")
         .replace(/'/g, "&#039;");
 }

Related Tutorials