Nodejs Utililty Methods String Title Case

List of utility methods to do String Title Case

Description

The list of methods to do String Title Case are organized into topic(s).

Method

toTitleCase()
String.prototype.toTitleCase = function() {
    var i, j, str, lowers, uppers;
    str = this.replace(/([^\W_]+[^\s-]*) */g, function(txt) {
        return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
    });
    lowers = ['A', 'An', 'The', 'And', 'But', 'Or', 'For', 'Nor', 'As', 'At',
        'By', 'For', 'From', 'In', 'Into', 'Near', 'Of', 'On', 'Onto', 'To', 'With'];
    for (i = 0, j = lowers.length; i < j; i++)
        str = str.replace(new RegExp('\\s' + lowers[i] + '\\s', 'g'),
...
toTitleCase()
String.prototype.toTitleCase = function() {
    return this.replace(/([\w&`'??"?.@:\/\{\(\[<>_]+-? *)/g, function(match, p1, index, title) {
        if (index > 0 && title.charAt(index - 2) !== ":" &&
          match.search(/^(a(nd?|s|t)?|b(ut|y)|en|for|i[fn]|o[fnr]|t(he|o)|vs?\.?|via)[ \-]/i) > -1)
            return match.toLowerCase();
        if (title.substring(index - 1, index + 1).search(/['"_{(\[]/) > -1)
            return match.charAt(0) + match.charAt(1).toUpperCase() + match.substr(2);
        if (match.substr(1).search(/[A-Z]+|&|[\w]+[._][\w]+/) > -1 || 
          title.substring(index - 1, index + 1).search(/[\])}]/) > -1)
...
toTitleCase()
String.prototype.toTitleCase = function() {
  return this.replace(/(^|\s)[a-z]/g, function($1){return $1.toUpperCase();});
};
String.prototype.numberValue = function() {
  return Number(this.replace(/[^0-9\.\-]+/, ""));
};
String.htmlEncodeMap = {
  "&": "&amp;",
  "'": "&#39;",
...
toTitleCase()
String.prototype.toTitleCase = function() {
  return this.replace(/([\w&`'??:\/\{\(\[<>_]+-? *)/g, function(match, p1, index, title) {
    if (index > 0 && title.charAt(index - 2) !== ":" && match.search(/^(a(nd?|s|t)?|b(ut|y)|en|for|i[fn]|o[fnr]|t(he|o)|vs?\.?|via)[ \-]/i) > -1)
      return match.toLowerCase();
    if (title.substring(index - 1, index + 1).search(/['"_{(\[]/) > -1)
      return match.charAt(0) + match.charAt(1).toUpperCase() + match.substr(2);
    if (match.substr(1).search(/[A-Z]+|&|[\w]+[._][\w]+/) > -1 || title.substring(index - 1, index + 1).search(/[\])}]/) > -1)
      return match;
    return match.charAt(0).toUpperCase() + match.substr(1);
...
toTitleCase()
String.prototype.toTitleCase = function() {
    var i, j, str, lowers, uppers;
    str = this.replace(/([^\W_]+[^\s-]*) */g, function(txt) {
        return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
    });
    lowers = ['A', 'An', 'The', 'And', 'But', 'Or', 'For', 'Nor', 'As', 'At',
        'By', 'For', 'From', 'In', 'Into', 'Near', 'Of', 'On', 'Onto', 'To', 'With'];
    for (i = 0, j = lowers.length; i < j; i++)
        str = str.replace(new RegExp('\\s' + lowers[i] + '\\s', 'g'),
...
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', 
...
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();});
toTitleCase()
var titleCase   = /\w\S*/g; 
String.prototype.toTitleCase = function() {
    return this.replace(titleCase, function (word) {
        return word.capitalize();
    });
};
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();
toTitleCasetoTitleCase()
String.prototype.toTitleCase = function toTitleCase() {
  return this.split(' ').map(a => a[0].toUpperCase() + a.slice(1)).join(' ');
};