Here you can find the source of toCapitalCase( allCapsWordLength )
var ID_DELIMITER = '-'; function sanitizeString( input ) { //return input.replace( /\W/g, ID_DELIMITER ); return input.split( /\W/g )[1]; } String.prototype.toCapitalCase = function( allCapsWordLength ) { if ( isNaN( parseInt( allCapsWordLength ) ) ) { allCapsWordLength = 3;//w ww . j a va 2 s . c o m } var words = this.split(' '); var capitalCaseString = ''; for ( var i = 0; i < words.length; i++ ) { var word = words[i]; if (word.length > allCapsWordLength) { capitalCaseString += word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase() + ' '; } else { capitalCaseString += word.toUpperCase() + ' '; } } return capitalCaseString; }; module.exports = sanitizeString;
String.prototype.capitalize_all = function() { var words = []; this.split(' ').forEach(function(word) { words.push( word.charAt(0).toUpperCase() + word.slice(1) ); }); return words.join(" "); String.prototype.capitalize_first = function() { return this.charAt(0).toUpperCase() + this.slice(1); ...
String.prototype.capitalize = function capitaliseFirstLetter() { return this.charAt(0).toUpperCase() + this.slice(1); };
String.prototype.capitalize = function capitalize() { return this[0].toUpperCase() + this.slice(1); };
String.prototype.capitalize = jCube.String.capitalize = function () { return this.charAt(0).toUpperCase() + this.substring(1).replace( /\s[a-z]/g, function(s){ return s.toUpperCase(); });
String.prototype.capitalizingFirstLetterOfEveryWord = function () { return this.replace(/(?:^|\s)\S/g, function(m){ return m.toUpperCase(); }); };
String.prototype.toCapitalizeCase = function () { return this.charAt(0).toUpperCase() + this.slice(1); };
String.prototype.ucFirst = function() { var str = this; if(str.length) { str = str.charAt(0).toUpperCase() + str.slice(1); return str; };
String.prototype.ucFirst = function () { return this.charAt(0).toUpperCase() + this.slice(1); };
String.prototype.ucFirst = function() return this.charAt(0).toUpperCase() + this.substr(1);