|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Initial caps regex
Hey I've just been playing with CFMX regular expressions and thought I'dMatthew Walker 06/19/03 09:43 P I would say gratifyingly simple. Very elegant, too.Ben Doom 06/20/03 09:50 A At least you haven't been struggling with CFCs and cryptic error messagesMatthew Walker 06/20/03 08:20 P Only about 5 months -- ironically, our test box is CFMX, because we've beenBen Doom 06/21/03 01:52 P Hey I've just been playing with CFMX regular expressions and thought I'd share. You can write this to force initial caps: <cfset initialCapsText = rereplace(text, "(\b\w)", "\u\1", "all")> \b marks a transition to or from a word, \w marks an alphanumeric, \u means capitalize the next char, and \1 is a back reference. Alarmingly simple, eh? I would say gratifyingly simple. Very elegant, too. But only on MX, cries the boy trapped in 5. -- Ben Doom Programmer & General Lackey Moonbow Software, Inc : -----Original Message----- : : Sent: Thursday, June 19, 2003 9:41 PM : To: CF-Talk : Subject: Initial caps regex : : : Hey I've just been playing with CFMX regular expressions and thought I'd : share. You can write this to force initial caps: : : <cfset initialCapsText = rereplace(text, "(\b\w)", "\u\1", "all")> : : \b marks a transition to or from a word, \w marks an : alphanumeric, \u means : capitalize the next char, and \1 is a back reference. Alarmingly : simple, eh? : : : At least you haven't been struggling with CFCs and cryptic error messages for a year! ;-) ----- Excess quoted text cut - see Original Post for more ----- Only about 5 months -- ironically, our test box is CFMX, because we've been trying to migrate. However, the original migration date was cancelled because my boss's dad had a heart attack, and when we finally tried to migrate it (me being in KY, my bosses and the box in FL) it was unsuccessful and we had to roll back to CF5. :-( I'd love to be struggling with CFC's -- I was trained on C/C++ and miss objects. I write UDFs for just about everything, and the error messages I've run into, while occasionally cryptic, were often more helpful than the 5 ones. -- Ben Doom Programmer & General Lackey Moonbow Software, Inc : -----Original Message----- : : Sent: Friday, June 20, 2003 8:18 PM : To: CF-Talk : Subject: Re: Initial caps regex : : : At least you haven't been struggling with CFCs and cryptic error messages : for a year! ;-) : : ----- Original Message ----- : From: "Ben Doom" <bdoom-hof@moonbow.com> : To: "CF-Talk" <cf-talk@houseoffusion.com> : Sent: Saturday, June 21, 2003 1:48 AM : Subject: RE: Initial caps regex : : : > I would say gratifyingly simple. Very elegant, too. : > : > But only on MX, cries the boy trapped in 5. : > : > : > -- Ben Doom : > Programmer & General Lackey : > Moonbow Software, Inc : > : > : -----Original Message----- : > : : > : Sent: Thursday, June 19, 2003 9:41 PM : > : To: CF-Talk : > : Subject: Initial caps regex : > : : > : : > : Hey I've just been playing with CFMX regular expressions and : thought I'd : > : share. You can write this to force initial caps: : > : : > : <cfset initialCapsText = rereplace(text, "(\b\w)", "\u\1", "all")> : > : : > : \b marks a transition to or from a word, \w marks an : > : alphanumeric, \u means : > : capitalize the next char, and \1 is a back reference. Alarmingly : > : simple, eh? : > : : > : : > : : > :
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||