Unfortunately, I need this function for both ColdFusion and for somebody else to use with the same data using Crystal Reports.
>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? > > > >> >> 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. >> >> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Create robust enterprise, web RIAs. Upgrade to ColdFusion 8 and integrate with Adobe Flex http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:1060 Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.21
