Is there a simple way to convert a string to title case? E.g. john smith becomes John Smith. I\'m not looking for something complicated like John R
john smith
John Smith
A slightly more elegant way, adapting Greg Dean's function:
String.prototype.toProperCase = function () { return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); };
Call it like:
"pascal".toProperCase();