D'oh. That obviously complicates things. Ok... if the second part always has two words then I think this should work: ReReplaceNoCase( Input , '([A-Z]+)-([a-z]+) ([a-z]+)' , '\U\1\E-\L\u\2 \u\3\E' )
(assuming the Crystal regex supports the \U..\E syntax - not all regex engines do.) On 9/11/07, Rebecca Wells <[EMAIL PROTECTED]> wrote: > > 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. > >> > >> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion 8 - Build next generation apps today, with easy PDF and Ajax features - download now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:1062 Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.21
