Nodejs String Humanize humanize()

Here you can find the source of humanize()

Method Source Code

String.prototype.humanize=function(){
   return this[0].toUpperCase()+this.replace(/_/g," ").slice(1);
};

Related

  1. humanize()
    String.prototype.humanize = function() {
      var str;
      str = this.replace(/_id$/, "").replace(/_/g, ' ').replace(/([a-z\d]*)/gi, function(match) {
        return match.toLowerCase();
      });
      return str.split('.').pop();
    };
    
  2. humanize()
    String.prototype.humanize = function() {
        var str;
        str = this.replace(/_id$/, "").replace(/_/g, ' ').replace(/([a-z\d]*)/gi, function(match) {
            return match;
        });
        return str.split('.').pop().charAt(0).toLowerCase() + str.split('.').pop().slice(1);
    };
    
  3. humanize()
    String.prototype.humanize = function ()
      var str = this;
      for (var i = 0; i < str.length; i++)
        if (str[i] == str[i].toUpperCase())
          str = str.substr(0, i) +' '+ str[i].toLowerCase() + str.substr(i + 1);
          i++;
    ...
    
  4. humanize()
    String.prototype.humanize = function() {
      var s = this.trim().toLowerCase().replace(/[_]+/g, ' ');
      s = s.replace(/^(.)|\s(.)/g, function($1) {
        return $1.toUpperCase();
      });
      return s;