Avery useful function for dealing with strings. Uses a regular expression (RE) to search a string for a string pattern and replace it with another. The search is case-sensitive, and it has attributes you can set to control case.
REReplace(string, reg_expression, substring [, scope ])
Since there is no Proper Case or Title Case in CF we can use REReplace to do it.
#rereplace( "erics test lab", "b([a-z])", "U1", "ALL")#
yields: Erics Test Lab
Or use it to modify spaces from strings to create URLs.
cfset myUrl="#rereplace( "Erics Test Lab", " ", "-l", "ALL")# .com"
yields: myUrl="erics-test-lab.com"
Don’t forget the scope variable. Valid values are 1 (default) or ALL. You can use this as part of SQL statements or CFIF logic or even to edit text. The string to replace can be a dynamic variable too.