Need help changing text case

A while back, I wrote an auto-generating breadcrumb script that builds out a list of breadcrumb links on our site based on folder structure. Since we’re a gov’t agency, it’s acronym city here, and a lot of folders are named after acronyms. I wrote a condition into the script that considers anything shorter than 5 characters to be an acronym, and shows the link text in all caps.

Also, some of the folders need to be two words, so in that case we name the folder with an underscore, and the breadcrumb script replaces that with a space in the link text.

So a folder named: this_folder

Creates a breadcrumb link like this:

<a href="/this_folder/">This Folder</a>

This has worked swimmingly, until today, when someone created a two-word folder where the first word was an acronym and the second wasn’t. (ex: us_roads). It displays in title case (Us Roads) and I need it to display US Roads.

I’m trying to think of a way to do it with rereplace() and regexes, but I’m lousy with them.

Right now I have this code:

<cfset linktext = #replace(i,"_"," ","ALL")#>
	<cfif #len(linktext)# lte 4>
		<cfset linktext = #ucase(linktext)#>
		<cfset linktext = #rereplace(linktext,"(\\b\\w)","\\u\\1","ALL")#>

Which, while clunky, works. I’m thinking I could maybe swap the whole thing with one rereplace() if I knew what to use for the regex.