Javascript String escape()
String.prototype.escape = function() { return this.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/])/g,'\\$1') }
String.prototype.escape = function() { return this.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); };
// add escape for string String.prototype.escape = function () { var entityMap = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''' };/*from w w w . j a v a 2 s . c om*/ return this.replace(/[&<>"']/g, function (s) { return entityMap[s]; }); };
var ENCODE_HTML_CHARACTERS = { '&': 'amp', '\'': '#039', '"': 'quot', '<': 'lt', '>': 'gt' }; String.prototype.escape = function() { return this.replace(/(&|'|"|<|>)/g, function(m, k) { return ('&' + ENCODE_HTML_CHARACTERS[k] + ';') || k; });// ww w .ja v a 2s . c o m };
// Escape html characters. String.prototype.escape = function() { var tagsToReplace = { '&': '&', '<': '<', '>': '>' };// ww w .ja v a2s . co m return this.replace(/[&<>]/g, function(tag) { return tagsToReplace[tag] || tag; }); };
String.prototype.escape = function() { var escape = document.createElement('textarea'); escape.textContent = this;/*ww w . j a v a 2 s .com*/ return escape.innerHTML; }
String.prototype.escape = function() { return this/* ww w . j a v a2 s . c o m*/ .replace(/&(?!\w+;)/g, '&') .replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"'); };