Nodejs String Title Case cleanTitle()

Here you can find the source of cleanTitle()

Method Source Code

/**//from  w  w  w .  j  a  va  2 s . co m
 * Clean up string.
 */
String.prototype.cleanTitle = function() {
  var title = this.trim().replaceHtmlEntites();
  title = encodeURI(title);
  return title.replace(/&/g, '%26').replace(/#/g, '%23');
};

Related

  1. title()
    String.prototype.title = function() {
        return this.replace(/\w\S*/g, function(txt) {
            return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
        });
    };
    
  2. title()
    String.prototype.title = function() {
      return this.charAt(0).toUpperCase() + this.slice(1);
    };
    module.exports = String;
    
  3. titleCase()
    String.prototype.titleCase = function () {  
      return this.replace(/\w\S*/g, (txt) => {
        return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
      });
    };
    
  4. titleCase()
    String.prototype.titleCase= function()
        return this.charAt(0).toUpperCase() + this.substr(1);