Javascript String capitalize()
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); };
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }; function word_cap(str) { return str.split(' ').map(function(word) { return word.capitalize(); }).join(' ');//from ww w. ja v a 2 s. co m }
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }
string.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }
String.prototype.capitalize = function(){ return this.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } ); };// ww w . j a va 2 s . co m
/*//w w w.j av a 2 s.c om Capitalize the first letter of words */ String.prototype.capitalize = function () { 'use strict'; return this.replace(/(?:^|\s)\S/g, function (a) { return a.toUpperCase(); }); };
'use strict';/*from w w w. j a v a 2 s . c o m*/ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase(); };
dojo.provide("cvdj.capstring"); String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); };
function capitalize() { const text = this;/* w ww. j a va2 s. com*/ return text ? [text[0].toUpperCase(), text.slice(1)].join('') : text; } String.prototype.capitalize = capitalize;
"use strict";/* w w w . j ava 2s . com*/ String.prototype.capitalize = String.prototype.capitalize || function() { var first = this.substring(0, 1); return first.toUpperCase() + this.substring(1); };
String.prototype.capitalize = function(){ return this.charAt(0).toUpperCase() + this.slice(1); };
String.prototype.capitalize = function() { return this.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); }); }
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); };
Function.isFunction = function (f) { return 'function' == typeof (f); } String.prototype.capitalize = function () { return this.charAt(0).toUpperCase() + this.slice(1); }
/*//from ww w . j a v a 2 s . co m * Include with eval(fs.readFileSync()); */ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }
String.prototype.capitalize = function() { return this.replace(/\b\w/g, function(l){ return l.toUpperCase() }); };
String.prototype.capitalize = function() { return this.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); }); };
/**/*ww w. j av a2 s. c o m*/ * Capitalize a string * @return {String} */ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }
var currentTask;//from www. ja va 2s. co m //Dictionary of words var dictionary = {}; var validWordArray = new Array(); String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); };
var mainUrl = 'MY DOMAIN IN USE'; /** Funcion para capitalizar **/ String.prototype.capitalize = function() { return this.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); }); };
String.prototype.capitalize = function() { return this[0].toUpperCase() + this.slice(1); }
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }
//Include helper functions here String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } function testAlert(name) { alert("."+name); };
String.prototype.capitalize = function () { 'use strict'; return this.charAt(0).toUpperCase() + this.slice(1); };
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase(); };
/**/*from www .j a v a2s . c o m*/ * Capitalizes the first letter of the string. * @returns {string} The string with the first letter capitalized. */ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); };
String.prototype.capitalize = function(){ var first_char = this.charAt(0).toUpperCase(); return this.replace(/^./,first_char); };
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } export default {};/*from w w w . j a v a 2 s. c o m*/
String.prototype.capitalize = function() { return this.replace(/(^|\/)([a-z])/g, (match) => match.toUpperCase()); } export default String;/*from w w w . j a va2 s .co m*/
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1) }
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); }
String.prototype.capitalize = function() { return this.slice(0, 1).toUpperCase() + this.slice(1).toLowerCase(); };
String.prototype.capitalize = function() { return this[0].toUpperCase() + this.slice(1); };
// Capitalize the first letter of the string String.prototype.capitalize = function () { return this.charAt(0).toUpperCase() + this.slice(1); }
String.prototype.capitalize = function() { return this.trim() .split(' ') .map(word => {// w ww. ja v a 2 s. co m return word.replace(/^[a-z]/g, word.charAt(0).toUpperCase()) }) .join(' ') }
'use strict'//from w w w .j a va2 s.c o m String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } const idlescape = {} idlescape.vues = {} idlescape.models = {} idlescape.models.spots = {} idlescape.player = {} idlescape.player.bank = {}
String.prototype.capitalize=function(){ return this[0].toUpperCase()+this.slice(1).toLowerCase() } function cleanItUp(s) { var rs=s.replace(/[^a-z]+/gi, '') return rs.length<5 ? '' : rs.match(/.{5}/g).map(e=>e.capitalize()).join` ` }
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } function titleize(array, callback) { let words = array.map(function(word) { return word.charAt(0).toUpperCase() + word.slice(1); });//from ww w . j av a2 s. c om words.forEach(function(word) { callback(word); }); }
//+ Jonas Raoni Soares Silva //@ http://jsfromhell.com/string/capitalize [rev. #2] String.prototype.capitalize = function(){ return this.replace(/\S+/g, function(a){ return a.charAt(0).toUpperCase() + a.slice(1).toLowerCase(); });// w w w . j av a 2 s. c om };
var file = require('fs'); String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } file.readFileSync(process.argv[2]).toString().split('\n').forEach(function(line) { var words = line.split(' '); var sentence = []; for (i = 0; i < words.length; i++) { sentence.push(words[i].capitalize()); }//from w w w . j a v a 2s . c om console.log(sentence.join(' ')); });
/**/*from w w w .jav a 2 s . c o m*/ * Question: Capitalize fist letter in name. */ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase(); }; console.log('JANE'.capitalize()); console.log('john'.capitalize());
String.prototype.capitalize = function() { return this[0].toUpperCase() + this.substr(1, this.length-1); }; String.prototype.titleize = function() { var res = [];//from w ww.j a va 2 s .c o m var parts = this.split(/_| /); $.each(parts, function(index, part) { res.push(part.capitalize()); }); return res.join(" "); };
String.prototype.capitalize = function() { return this[0].toUpperCase() + this.slice(1) }
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }; Array.prototype.capitalize = function() { return this.map(function(i) { return i.capitalize(); })/* w w w . j ava2 s. co m*/ };
String.prototype.capitalize = function(){ var sa = this.replace(/-/g,' '); var saa = sa.toLowerCase(); var sb = saa.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } ); var sc = sb.replace(/\s+/g, '-'); return sc;//from w w w.j av a2 s . c o m };
String.prototype.capitalize = function(){ return this.replace(/\w+/g, function(a){ return a.charAt(0).toUpperCase() + a.slice(1).toLowerCase(); });/*from w ww . ja va 2 s . c om*/ };
/*/*from w ww. j a v a 2 s . c o m*/ * Capitalize * http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript */ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } module.exports = {}
"use strict";// ww w .j a va 2 s . c o m String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }
/**/*from w ww. java2s .co m*/ Add a function like Python's capitalize to JavaScript strings. */ String.prototype.capitalize = function(){ return this.charAt(0).toUpperCase() + this.slice(1); }
// For capitalizing the first letter of a string String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }
// Small prototype library for Online Notifier String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }
"use strict";/*from ww w . j a va2s. c o m*/ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }; module.exports = function(pageName) { return { title: pageName.capitalize(), url: pageName, id: pageName, visible: true }; };
////from w w w . j a v a 2 s . c o m String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }
String.prototype.capitalize = function() { return this.toUpperCase() }
String.prototype.capitalize = function() { return this.replace(/^[a-z]/, function(m){ return m.toUpperCase(); }) }
String.prototype.capitalize = function() { return this.setCharAt(0, this.charAt(0).toUpperCase()); };
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }; if(typeof String.prototype.trim !== 'function') { String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); }/* w w w. ja va 2 s.c om*/ }
// section: String.prototype // desc: Methods added to all strings. // func: capitalize() // desc: returns a copy of the string with the first letter capitalized and the rest lowercase. String.prototype.capitalize = function () { return this.substring(0,1).toUpperCase() + this.substring(1,this.length).toLowerCase(); }; // endsection//from w ww. jav a 2s. c om
(function(){String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }; String.prototype.clean = function() { str = this.replace(/'/g, '').replace(/\s/g, '').replace(/_/g, ''); return str;/*from w w w.java 2 s.com*/ }; })();
// Makes first letter uppercase String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); };
String.prototype.capitalize = function () { let splitString = this.split('') splitString.unshift(splitString.shift().toUpperCase()) return splitString.join('') }
String.prototype.capitalize = function(){ if(this.charCodeAt(0)<97) return this.toString(); else//from w w w . ja v a 2s .c om return String.fromCharCode(this.charCodeAt(0)-32) + this.slice(1); };
/* best practice */ String.prototype.capitalize = function () { let c = this.charCodeAt(0) if (97 <= c && c <= 122) c -= 32 return String.fromCharCode(c) + this.slice(1) }
/**//from w w w . j ava 2 s .co m * Capitalizes the first letter of a string and downcases all the others. * * @function external:String.prototype.capitalize * @return {string} * @example * 'hello'.capitalize() === 'Hello' * 'HELLO WORLD!'.capitalize() === 'Hello world!' */ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); };
String.prototype.capitalize = function() { var t;// ww w .j a v a 2 s . c o m var capital = this; var cap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; var low = 'abcdefghijklmnopqrstuvwxyz'; for (var i=0;i<low.length;i++) { if (capital[0] === low[i]) { return t = cap[i] + capital.slice(1); } else t = capital; } return t; } console.log("the first character of this sentence is not a letter".capitalize()); // https://www.codewars.com/kata/capitalize-first-letter-of-a-string/discuss
/*/*from www . ja v a2 s . c o m*/ String.capitalize() rog?o sampaio 2008, Jan 4 Return: Capitalized string Sample: "I am the best and the girls love me!".capitalize() == "I Am The Best And The Girls Love Me!" */ 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(); }); }
/**//from www .j a v a 2 s .c o m * String#capitalize() -> String * * Capitalizes the first letter of a string and downcases all the others. * * ##### Examples * * 'hello'.capitalize(); * // -> 'Hello' * * 'HELLO WORLD!'.capitalize(); * // -> 'Hello world!' **/ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); };
String.prototype.capitalize = function () { var obj = this; var newString = ""; for (i in obj){ newString += obj[i];//from w w w .j av a 2 s. c o m if (i == obj.length-1){ break; } } if (newString[0].charCodeAt()>96&&newString[0].charCodeAt()<123) { var firstLetter = newString[0].charCodeAt(); var newString = String.fromCharCode(firstLetter-32)+newString.substring(1,newString.length); return newString; } else { return newString; } }
String.prototype.capitalize = function() { console.log(this.charAt(0));//from w w w .j a v a 2s .c om console.log(this.slice(1)); return this.charAt(0).toUpperCase() + this.slice(1); }
#!/usr/bin/js/*ww w.j av a2 s . c o m*/ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } function generateHashtag (str) { return (str.length > 140 || str.length < 1) ? false : "#" + str.split(" ").map(function(n){ return n.capitalize() }).join(''); } //console.log('lorne'.capitalize()); console.log(generateHashtag('')); console.log(generateHashtag('Lorne Greene')); console.log(generateHashtag('tina turner'));
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } function thousandSeperate(x) { try/*from w w w . j a va2 s . com*/ { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "); } catch (err) { return x; } } function phoneSeperate(x) { try { return x.toString().replace(/\B(?=(\d{2})+(?!\d))/g, " "); } catch (err) { return x; } } function rnd(min,max) { return Math.floor(Math.random()*(max-min+1)+min); }
////from w w w. j a v a 2 s .co m // Prototype additions // String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } var getCurrentDate = function() { var today = new Date(); var dd = today.getDate(); var mm = today.getMonth()+1; //January is 0! var yyyy = today.getFullYear(); if(dd<10) { dd='0'+dd }//from w ww . j av a 2 s .co m if(mm<10) { mm='0'+mm } today = yyyy+'-'+mm+'-'+dd; return today; }
String.prototype.capitalize = function() { return this.replace(/([\s\-_]|^)./g, function (match) { return match.toUpperCase(); });//from w w w. j a va 2 s.c o m }
// STRING PROTOTYPE String.prototype.capitalize = function() { return this.replace(/(^|\s)([a-z])/g, function(m, p1, p2) { return p1 + p2.toUpperCase(); });/* w w w .j a v a 2 s . c o m*/ };
String.prototype.capitalize = function capitalize() { return this[0].toUpperCase() + this.slice(1); };
// Add to standard prototypes String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }
/**// w w w. j av a 2s . c om * Capitalize a string. * * @return Capitalized string. */ String.prototype.capitalize = function () { return this.charAt(0).toUpperCase() + this.slice(1); };
String.prototype.capitalize = function() { sentence = this.split(' '); for(word in sentence) { sentence[word] = sentence[word].ucfirst(); }/*from w w w .j av a 2 s .c o m*/ return sentence.join(' '); }
/* $This file is distributed under the terms of the license in /doc/license.txt$ */ String.prototype.capitalize = function() { return this.substring(0,1).toUpperCase() + this.substring(1); };
/*/* w w w . j a v a 2 s .co m*/ * @return {String} string with the first letter in upper case */ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); };
/**//from www .j a v a2 s . c om * Capitalizes the first letter of a string and downcases all the others. * * @function module:String.prototype.capitalize * @return {string} * @example * 'hello'.capitalize() === 'Hello' * 'HELLO WORLD!'.capitalize() === 'Hello world!' */ String.prototype.capitalize = String.prototype.capitalize || function() { return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); };
/*// w w w.ja v a 2s . c o m * Objects extensions and support functions */ // We love Python capitalize()! String.prototype.capitalize = function(){ return this.replace(/^(.?)/, this.charAt(0).toUpperCase()); }
/**// www . j a v a 2s .co m * @overview Extensions to existing JavaScript object. * @author Dave Huffman * @copyright 2014 */ // Handle environments that don't provide a console. if (typeof console === 'undefined') { console = { debug: function () {}, dir: function () {}, info: function () {}, log: function () {}, warn: function () {} }; } /** * @returns {String} A capitalized version of this string. */ String.prototype.capitalize = function () { return this.charAt(0).toUpperCase() + this.slice(1); };
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } function getRandomArbitaryInt(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } function getRandomSubArray (array) { if (array.length < 4) return false; var randomSubArray = []; _.each(array, function (elem, i) { if (Math.random() > 0.5) { randomSubArray.push(elem);//from w ww . j a v a 2 s .c om } }) return randomSubArray.length > 3 && randomSubArray.length < Math.ceil(array.length*0.5) ? randomSubArray : getRandomSubArray(array); } function getRandomArbitrary(min, max) { return Math.random() * (max - min) + min; }
// JavascriptExtensions.js // Author: Bradley J. Spaulding // Created On: 2011-02-12 String.prototype.capitalize = function() { return this[0].toUpperCase() + this.substring(1, this.length); }
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase(); }; String.prototype.toTitleCase = function() { var words = this.split(' '); var compiledString = ''; for (var i = 0; i < words.length; i++) { compiledString += (' ' + words[i].capitalize()); } compiledString = compiledString.slice(1); return compiledString; }; function urlTitle(url) { var title = url.split('/').pop(); title = title.replace(/-/gi, ' '); title = title.toTitleCase();/*from w ww . j a v a 2 s . c om*/ return title; } // urlTitle('http://jdh11235.github.io/web-experiments/really-cool-experiment'); // => "Really Cool Experiment"
// find and replace string. also, capitalize replacement if string getting replaced is also in caps // http://www.freecodecamp.com/challenges/bonfire-search-and-replace String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }; String.prototype.isUpperCased = function() { return this.charAt(0) === this.charAt(0).toUpperCase(); }; function replace(str, before, after) { var arr = str.split(' '); var sIdx = arr.indexOf(before); if (before.isUpperCased()) { after = after.capitalize(); } arr[sIdx] = after;/* w w w . j a v a2 s . c o m*/ console.log(arr.join(' ')); return arr.join(' '); } replace("Let us go to the store", "store", "mall");
String.prototype.capitalize = function() { if (this.length <= 1) return this; var words = this.split(" "); for (var i in words) if (words[i][0] && words[i][0].match(/[A-Za-z]/)) words[i] = words[i].replace(new RegExp(words[i][0]),words[i][0].toUpperCase()); return words.join(" "); }
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); } function random(min, max){ randomPart = Math.round((max - min) * Math.random()); return randomPart + min; } function randomIn(array){ var length = array.length - 1; return array[random(0, length)]; }
// Capitalize a string String.prototype.capitalize = function (){ return this.charAt(0).toUpperCase() + this.slice(1); };
"use strict";/*from w ww. j a va2s . c om*/ String.prototype.capitalize = function() { return this.toUpperCase(); }; String.prototype.dasherize = function() { return this.split("_").join("-"); }; String.prototype.times = function(amount) { // return [].range(1, amount).map(function(){ // return this; // }).join(" "); var i = 0, result = []; while(i < amount) { result.push(this); i++; } return result.join(" "); }; String.prototype.blank = function() { var that = this.split(""); return that.every(function(element) { return element === " "; }) || this === ""; }; console.log("hello".capitalize()); console.log("border_bottom_width".dasherize()); console.log("Nicole".times(5)); console.log("".blank()); console.log(" ".blank()); console.log(" ".blank()); console.log(" a".blank());