I wouldn't bother using Regex for all of that, just the second half. Also,
Proper Casing is useful enough that I'd create a function for it.
So, quick one-line solution:
<cfset Output = UCase(ListFirst(Input,'-')) &'-'&
REReplaceNoCase(ListRest(Input,'-'),'\b([a-z])([a-z]*)\b','\u\1\L\2\E','all')/>
and, very quick functionised version:
<cfset Output = UCase(ListFirst(Input,'-')) &'-'&
PropCase(ListRest(Input,'-'))/>
<cffunction name="PropCase">
<cfreturn
REReplaceNoCase(Arguments[1],'\b([a-z])([a-z]*)\b','\u\1\L\2\E','all')/>
</cffunction>
However for a general Proper Case thing you'd possibly need to consider
things like names (eg: McDonalds, van Helsing, etc) and other oddities. I
think I've got a reasonably "smart" function somewhere if you need one, or
you can check cflib/etc.
Anyway, quick summary of important bit:
\u = uppercase next character
\L..\E = lowercase block of characters.
(you can also do \l and \U..\E)
Hope that makes sense?
On 9/11/07, Rebecca Wells <[EMAIL PROTECTED]> wrote:
>
> Example input: PBPW-UTILITY SYS
> Example output: PBPW-Utility Sys
> In other words, words following the dash (-) should be initial caps. The
> letters before the dash remain all caps.
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get involved in the latest ColdFusion discussions, product
development sharing, and articles on the Adobe Labs wiki.
http://labs/adobe.com/wiki/index.php/ColdFusion_8
Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:1059
Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.21