Nodejs String Normalize normalize(s)

Here you can find the source of normalize(s)

Method Source Code

/**//from  w w w  . j a va  2  s  .c  o m
 * Normalizes a string by replacing multiple-instances
 * of parameter `s` with the singular-instance.
 * ex. "///path//to/my//endpoint//".normalize('/') => "/path/to/my/endpoint/"
 */
String.prototype.normalize = function(s) {
    return this.replace(new RegExp(s + "+", "gm"), s);
};

Related

  1. nominalize()
    String.prototype.nominalize = function() {
      return this.charAt(0).toUpperCase() + this.slice(1);
    };
    
  2. normalize()
    String.prototype.normalize = function(){
      return this.trim().replace(/\s{2,}/g, ' ');
    };
    
  3. normalize()
    String.prototype.normalize = function () {
      return this.replace(/\W/g, "");
    
  4. normalize()
    String.prototype.normalize = function(){
        return this.replace(/\<[\/a-z \"=]*\>|\n/g,' ').toLowerCase();