Nodejs String Title Case toTitleCasetoTitleCase()

Here you can find the source of toTitleCasetoTitleCase()

Method Source Code

String.prototype.toTitleCase = function toTitleCase() {
    return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
};

Related

  1. toTitleCase()
    String.prototype.toTitleCase = function() {
        var i, str, lowers, uppers;
        str = this.replace(/([^\s:\-])([^\s:\-]*)/g, function(txt) {
            return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
        });
        lowers = ['A', 'An', 'And', 'As', 'At', 'But', 'By', 'For', 'From', 'If', 
                  'In', 'Into', 'Near', 'Nor', 'Of', 'On', 'Onto', 'Or', 'That', 
                  'The', 'To', 'With', 'Via', 'Vs', 'Vs.', 
                  'Um', 'Uma', 'E', 'Como', 'Em', 'No', 'Na', 'Mas', 'Por', 
    ...
    
  2. toTitleCase()
    String.prototype.toTitleCase = function() {
      var space = this.replace(/([A-Z])/g, function($1){return ' '+$1.toLowerCase();});
        return space.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
    
  3. toTitleCase()
    var titleCase   = /\w\S*/g; 
    String.prototype.toTitleCase = function() {
        return this.replace(titleCase, function (word) {
            return word.capitalize();
        });
    };
    
  4. toTitleCase(n)
    String.prototype.toTitleCase = function (n) {
      var string = this;
      if (1 !== n) string = string.toLowerCase();
      return string.replace(/\b[a-z]/g, function (result) { return result.toUpperCase() });
    var hideObj = function (objclass) {
      console.log(objclass);
        $(objclass).hide();
    
  5. toTitleCasetoTitleCase()
    String.prototype.toTitleCase = function toTitleCase() {
      return this.split(' ').map(a => a[0].toUpperCase() + a.slice(1)).join(' ');
    };