Essentially I want to undo the escapeHTML() function I found below, after I used it.
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
function unescapeHtml(safe) {
return safe
.replace("&", /&/g)
.replace("<", /</g)
.replace( ">", />/g)
.replace(""", /"/g)
.replace("'", /'/g);
}
var a = escapeHtml("<div> yo & yo squirrl's </div>");
var b = unescapeHtml(a);
console.log(a);
console.log(b);//should log "<div> yo & yo squirrl's </div>"
I tried the obvious but no deal. http://jsfiddle.net/ej6bX/
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…