Javascript String humanize()

Description

Javascript String humanize()


String.prototype.humanize = function() {
   return this.replace('_', ' ').capitalize();
};

Javascript String humanize()

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

Javascript String humanize()

String.prototype.humanize = function() {
    var str;/*from ww  w  . ja v a  2s.c  om*/
    str = this.replace(/_id$/, "").replace(/_/g, ' ').replace(/([a-z\d]*)/gi, function(match) {
        return match.toLowerCase();
    });

    return str.split('.').pop();
};

Javascript String humanize()

String.prototype.humanize = function() {
  return this.replace(/[_-]/g, ' ')
    .replace(/(\w+)/g, function(match) {
      return match.charAt(0).toUpperCase() + match.slice(1);
    });/*from  ww  w  . j  a  v a2s . co m*/
};

Javascript String humanize()

String.prototype.humanize = function() {
    var str;//from w  w w . ja v a  2  s .c om
    str = this.replace(/_id$/, "").replace(/_/g, ' ').replace(/([a-z\d]*)/gi, function(match) {
        return match;//.toLowerCase();
    });
    return str.split('.').pop().charAt(0).toLowerCase() + str.split('.').pop().slice(1);
};



PreviousNext

Related