National Regular Expression Day And Reflections On My Own Journey

Posted May 30, 2008 at 10:22 AM

Tags: ColdFusion, Work

With National Regular Expression Day coming up this Sunday, I was taking some time to reflect on my own journey into the land of regular expressions. I have really only come to love regular expressions in the last 3 or 4 years. Before that, I knew they existed, and I know people used them, but I really didn't know anything about them. It all seemed like some voodoo black magic to me; somehow these crazy strings of seemingly random letters and symbols were finding sub strings and creating new strings. I didn't understand what the heck was going on.

I actually made a bit of a fool of myself back when I was just starting to learn ColdFusion. I saw that there was a Find() method and REFind() method and I didn't realize that "RE" stood for "regular expression". I thought it was "re" as in "REfurnish" or "REpaint". I even asked a co-worker one time:

"Hey, what's the point of the refind() function? If I can use Find() to get it the first time, why would I ever need to refind() it?"

Ok, so that's pretty embarrassing to admit, but hey, I didn't know what I was doing, I was just learning.

Even when the RE-methods were explained to me, I didn't use them - I couldn't. I still didn't know regular expressions. I was still using the Find() method; and when I had to, I was returning the sub-expressions - LEN and POS array. I only got into regular expressions when I started to work on data cleaning. It was actually Jim Curran of Nylon Technology who first taught me about regular expressions when he showed me how to use them in the Extended Find/Replace in HomeSite. I have to give big praise to Jim - he was really the one who got me started with regular expressions and showed me the light.

Once he got me started, I was hooked. The first time you write a regular expression and it makes your life easier - forget about it! There's no going back! You just want to keep writing regular expressions. You keep looking for places that they can be applied. You start to feel like you have this hugely effective tool in your box and all you want to do is find places to use it. I assume its like walking around with a concealed weapon or a Black Belt in Jujitsu - you just feel powerful and you walk with confidence.

As someone who knew nothing about regular expressions, I know they are intimidating; you look at large regular expressions and maybe you think to yourself - I am never gonna understand that. Well, I'm here to let you in on a little secret: regular expressions are NOT meant to be read; they are far too complicated and information-dense. I have a pretty good handle on regular expressions and I still have a very hard time reading expressions that other people have written. These expression are meaningful to the regular expression compiler, not to the human eye.

So, don't worry about reading them! Concentrate, instead, on writing them. Start simple and build on that. Check out my introductory tutorial. Do a little experimentation. The first time you match a pattern, I can guarantee that you're gonna feel that magic inside. This Sunday, on National Regular Expression Day, carve out a little time for yourself to sit down and do some REsearch and development. Get your feet wet. It might just be the best gift you've given yourself in years.


 
 
 

 
National Regular Expression Day - June 1st, 2008  
 
 
 

Post Comment  |  Ask Ben  |  Permalink  |  Print Page




Learning ColdFusion 9 - ColdFusion 9 tutorials, samples, examples, demos

Reader Comments

May 30, 2008 at 11:08 AM // reply »
76 Comments

"best gift you've given yourself in years."

Indeed.

I'm glad you're doing the nat'l regex day. I hope it inspires someone or gives them the confidence to try regex, and realize that it doesn't have to be a dark art.


May 30, 2008 at 12:47 PM // reply »
6,516 Comments

@Sammy,

I have felt that way about many things. XML, XPath, XSLT, Regular Expressions... I used to look at all these things as things I just didn't know anything about and its so much to learn, and I don't have time, and pfooey!

But then, you take a few hours and look into it and suddenly you realize that it was all just a big misunderstanding. This stuff can be complicated, but it's never nearly as complicated as you think it is. Then suddenly, you have all these new ways of doing stuff.


May 30, 2008 at 1:13 PM // reply »
15 Comments

As /s are used in a number of languages as indicators of a regular expression object, perhaps the /'s in your poster should be around the date rather than in the middle of it.


May 30, 2008 at 11:41 PM // reply »
102 Comments

I feel like I'm always pimping this application (even though I have absolutely no knowledge of the author or the site), but it is a really great RegEx tester.

http://gskinner.com/RegExr/

It is a Flex application (there is an AIR version also), which allows you to add the text you are trying to match, and type in your regular expression. As you add complexity to your expression, it will highlight what is being matched. You can also do a replace rather than just a find, but it really is a great application.


May 31, 2008 at 2:22 PM // reply »
6,516 Comments

@Gareth,

That's an awesome little tool. I like the way you can hover over the matches and it shows you the captured groups.


Jun 5, 2008 at 8:45 AM // reply »
17 Comments

Congratulations on getting a mention from Webmonkey! That's a pretty significant honor in my book.

BTW, next year I hope you'll expand it to International Regular Expression Day. Let me know if you need help tracking down every instance of "National" and replacing it with "International."


Jun 9, 2008 at 9:11 AM // reply »
6,516 Comments

@Patrick,

Thanks man. Yeah, next year it will be international. Although, you will be happy to know that several of the winners were international. In fact, I had to ship a book to the Russian Federation. Not sure how to handle that next year as the shipping was more expensive than the actual book.

Next year, we can rock:

(?:inter)?national regular expression day


Post Comment  |  Ask Ben

Recent Blog Comments
Nov 21, 2009 at 11:03 AM
Groovy Operator Overloading Does Not Work In The ColdFusion Context
Hi Ben, Thanks for this informative post. Now I am reading ur old posts too ... read »
Nov 21, 2009 at 10:56 AM
HostMySite.com Has The Best ColdFusion Hosting
@Mehul, Yes very nice people, however several downtimes per day which was not acceptable. Hence we had to move out. I am glad you are having good luck with them so far. ... read »
Nov 20, 2009 at 11:32 PM
Five Months Without Hungarian Notation And I'm Loving It
I've used headless camel case for years for not only ColdFusion variables, but also SQL tables and fields... pretty much everything involving code. I also subscribe to the "don't abbreviate and clea ... read »
Nov 20, 2009 at 11:00 PM
Five Months Without Hungarian Notation And I'm Loving It
@Marcel, Yeah, I always err on the side of longer but more readable variable names. As for the camel casing of CF methods and the headless camel casing of custom items, I get around this by always ... read »
Nov 20, 2009 at 10:56 PM
Five Months Without Hungarian Notation And I'm Loving It
I use the following and love it: my.namespace.MyComponents.functionMethodsOrUDF() CONSTANT_VALUES_OR_PROPERTIES One thing I always try is to CamelCaseBuiltInColdFusionFunctions() so others can tell ... read »
Nov 20, 2009 at 5:38 PM
Learning ColdFusion 8: CFImage Part I - Reading And Writing Images
Hi Ben, Great article. I've been looking around to see if ColdFusion image engine can programatically create the following "wrap around" effect: http://www.creativepro.com/article/photoshop-s-she ... read »
Nov 20, 2009 at 5:35 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
@Dave: I talked to Gert he suggested: <cfhttp method="get" url="http://{some cf website}" result="stuff" addtoken="yes" /> Note the addition of cfhttp attribute addtoken. That should persist y ... read »