Capitalizing the first letter of each word – a common need for sure. There is a function for this on cflib but it didn’t work for me. No errors but it wasn’t returning what I expected. I came across this function that works, and does so with much less code:
<cffunction name="CapFirst" access="public" output="false" returntype="String">
<cfargument name="inputString" required="false" type="String" default="" />
<cfreturn rereplace(lcase(arguments.inputString), "(\b\w)", "\u\1", "all") />
</cffunction>
I found this snippet on the WeCodeThings blog. Good stuff.

Jake says:
You can do this with CSS too: element { text-transform:capitalize; }
17 March 2010, 9:32 pmRyan says:
Thats a great idea, that will work in many cases but it doesn't seem to work where I needed it yesterday – inside a select option.
18 March 2010, 7:24 amziggy says:
That ruins acronyms and other all-cap words.
20 March 2010, 11:21 pmRyan says:
True, perhaps it could be improved upon. In my case the text I was working on was all caps already, so adding a check to leave all cap words would not have worked for me.
21 March 2010, 8:44 am