Here you can find the source of htmlEscape()
/**//from w w w . j a v a2 s . c o m * A utility method for escaping HTML tag characters. * <p>From Ruby on Rails.</p> * * @returns {String} The escaped string. */ String.prototype.htmlEscape = function () { return this.replace(/"/g, '"').replace(/>/g, '>').replace(/</g, '<').replace(/&/g, '&'); };
String.prototype.htmlEscape = function (){ var escapedStr = String(this).replace(/&/g, '&'); escapedStr = escapedStr.replace(/\s/g, ' '); return escapedStr; var text = 'This is for testing'; console.log(text); text = text.htmlEscape(); console.log(text); ...
String.prototype.htmlEscape = function (){ var escapedStr = String(this).replace(/&/g, '&'); escapedStr = escapedStr.replace(/</g, '<'); escapedStr = escapedStr.replace(/>/g, '>'); escapedStr = escapedStr.replace(/"/g, '"'); escapedStr = escapedStr.replace(/'/g, "'"); return escapedStr;
String.prototype.htmlEscape = function() { return this.replace(/&/g, '&') .replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"') .replace(/'/g, '''); console.log('<script>'.htmlEscape());
"use strict"; String.prototype.htmlEscape = function() return this. replace(/&/g, '&'). replace(/</g, '<'). replace(/>/g, '>'). replace(/"/g, '"'). replace(/\n/g, '<br/>'); ...
String.prototype.htmlEscape = function() { var obj = document.createElement('div'); if (typeof obj.textContent != 'undefined') { obj.textContent = this; } else { obj.innerText = this; return obj.innerHTML; }; ...
String.prototype.normalizeHtml = function () { return this.replace(/(\n|\r|\t|\s\s+)/gm, "").trim(); };