toCapatalize
capitalize a String
String.prototype.toCapatalize = function()
{
var rExp = /(\w)(\w*)/;
var cResult="";
aWords = this.Split(" ");
for( var i = 0; i < aWords.length; i++ )
{
cResult += aWords[i].match( rExp)[1].toUpperCase()
+ aWords[i].match( rExp)[2].toLowerCase() + " ";
}
return cResult;
}
As h3h pointed out my function "very inefficient". His version is alot more slick. http://beta.xkr.us/js-ucwords.html.
Last Updated : 28/12/2005 @ 15:50
0 Comment(s).