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 22, 2009 at 4:30 AM
jQuery Live() Method And Event Bubbling
dasegtezr ... read »
Nov 22, 2009 at 4:03 AM
jQuery Live() Method And Event Bubbling
C_fieri ... read »
Nov 22, 2009 at 1:56 AM
Learning ColdFusion 9: Using CFQuery In CFScript Can Enable SQL Injection Attacks
Why adobe would give you script equivalent of cfquery is beyond me. I love cfquery tag because it helps me wriite clean sql, and get away from the horrible jdbc queries If I wanted to write javali ... read »
Nov 22, 2009 at 1:45 AM
Streaming Text Using ColdFusion's CFContent Tag And The Variable Attribute
The reason you would want to do this is to stream. Ack json/xml files to ria clients I used thus technique before because putting json in response stream causes debugging info to come thru As well a ... read »
Nov 21, 2009 at 6:47 PM
Hal Helms - Real World Object Oriented Development, Sarasota - Day Five
@charlie griefer, Thank you.. ... read »
Nov 21, 2009 at 5:15 PM
Using ColdFusion Structures To Remove Duplicate List Values
@Jose Galdamez, Oh heh yeah I didn't paste the whole code. I should have defined the vars -- my bad. It's fixed thou. Thanks. ... read »
Nov 21, 2009 at 4:49 PM
Styling The ColdFusion 8 WriteToBrowser CFImage Output
Great work yet again Ben! Whilst I didn't use this whole code, I copied some of your regex code for a similar problem with the lack of an alt attribute and unescaped ampersands in CFIMAGE for Railo 3 ... read »
Nov 21, 2009 at 1:13 PM
My First ColdFusion Builder Extension - Encrypting And Decrypting CFM / CFC Files
@Ben, Because I am pedantic, I just want to make sure that everyone knows there is absolutely no encryption going on. There is only encoding and obfuscation. The cfencode tool only obfuscates your C ... read »