List of utility methods to do String Humanize
humanize()String.prototype.humanize=function(){ return this[0].toUpperCase()+this.replace(/_/g," ").slice(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(); }; | |
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); }; | |
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++; ... | |
humanize()String.prototype.humanize = function() { var s = this.trim().toLowerCase().replace(/[_]+/g, ' '); s = s.replace(/^(.)|\s(.)/g, function($1) { return $1.toUpperCase(); }); return s; | |
humanize()String.prototype.humanize = function(){ var list = this.strip().split('_') first = list[0][0].toUpperCase() + list[0].substr(1,list[0].length) list = [first].concat(list.slice(1,list.length)) return list.join(' ').replace(/\s+/g,' ') | |
humanize()String.prototype.humanize = function () { return this.capitalize().replace(/_id$/, '').replace(/_/g, ' '); }; |