Skip to content

Instantly share code, notes, and snippets.

@garethflowers
Created April 9, 2013 16:54
Show Gist options
  • Select an option

  • Save garethflowers/5347367 to your computer and use it in GitHub Desktop.

Select an option

Save garethflowers/5347367 to your computer and use it in GitHub Desktop.
Uppercase the first character of each word in a string
if (typeof String.prototype.ucWords !== 'function') {
String.prototype.ucWords = function() {
return this.replace(/^([a-z])|\s+([a-z])/g, function($1) {
return $1.toUpperCase();
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment