Friday, August 22, 2008

Capitalize the first letter of every word in a string

Just a little post for today, I ran into a small situation where I wanted to capitalize the first letter of every word in a string and lowercase all others. There were various ways of doing this on the net, But I never found this way:

REReplaceNoCase(REReplaceNoCase(LCASE("TeSt tHIS sTrInG"),"(^[a-z])","\U\1"),"(\s[a-z])","\U\1")

It seems to work flawlessly and could so easily be turned into a function.

Have fun.