You are here:
Microsoft SQL 2008 Database Server Microsoft SQL 2008 Database Server

Capitalize the first letter in every word using ColdFusion | Regex to the rescue

I recently needed to capitalize (uppercase) the first letter of every word in a string. Without messing around using left, right, mid, FindNoCase, I found a handy snippet of code that uses a regular expression (regex) to do the trick.

The code goes a little bit like this:


This is a case sensitive replacement. To alter this simply use "ReReplaceNoCase" instead of ReReplace.

Nice, quick efficient and simple.