Nodejs Utililty Methods String Sanitize

List of utility methods to do String Sanitize

Description

The list of methods to do String Sanitize are organized into topic(s).

Method

sanitize()
String.prototype.sanitize = function() {
    return $('<div/>').text(this).html();
};
sanitize()
String.prototype.sanitize = function(){
    return this.replace(/</g, '&lt;').replace(/>/g, '&gt;');
sanitize()
String.prototype.sanitize = function() {
  return this
    .replace(/&/g, '&amp;')
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;')
    .replace(/"/g, '&quot;')
    .replace(/'/g, '&#39;')
sanitize()
String.prototype.sanitize = function () {
    var str = this.replace(/<[^>]*?>/g, '');
    return str;
};
sanitizeSpacing()
"use strict";
String.prototype.sanitizeSpacing = function () {
    return this
        .replace(/[\t\r\n\-]/g, ' ')  
        .replace(/  +/g, ' ')          
        .trim();                       
};
sanitizeToId()
String.prototype.sanitizeToId = function () {
  return this.replace(/\]/g, '').replace(/[^-a-zA-Z0-9:.]/g, '_');
};