National Regular Expression Day And Reflections On My Own Journey

Posted May 30, 2008 at 10:22 AM by Ben Nadel

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  
 
 
 



Reader Comments

May 30, 2008 at 11:08 AM // reply »
79 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 »
11,314 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 »
21 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 »
110 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 »
11,314 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 »
26 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 »
11,314 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 A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
Jun 20, 2013 at 3:15 AM
A Billion Wicked Thoughts By Ogi Ogas And Sai Gaddam
nice post i love it thanks 4 u :) ... read »
seb
Jun 20, 2013 at 2:32 AM
Working With Inherited Collections In AngularJS
@mike, @ben, The best article about scope and prototypal prototypical inheritance in angularjs is http://stackoverflow.com/questions/14049480/what-are-the-nuances-of-scope-prototypal-prototypical- ... read »
Jun 20, 2013 at 2:17 AM
ColdFusion NumberFormat() Exploration
Nice read thanks Ben, Is there a way to mask a negative number? Long story short in the finance sector when you go 'short' on a stock you want the price to fall this is a good thing because you are ... read »
Jun 20, 2013 at 1:09 AM
The Beauty Of The jQuery Each() Method
my html code : <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="nss.js"> ... read »
Jun 19, 2013 at 11:31 PM
Directive Link, $observe, And $watch Functions Execute Inside An AngularJS Context
@Ben, bunch to learn indeed, but thats fun part : ) ... read »
Jun 19, 2013 at 10:41 PM
Referencing ColdFusion Query Columns In A Loop Using Both Array And Dot Notation
Burdock-roots Are you going fat day by day? You need to be good for your family and make some money too. So we bring for you a best product that helps you to be more energetic every day. You will b ... read »
Jun 19, 2013 at 9:52 PM
Working With Inherited Collections In AngularJS
I recognize the applicability of your solution, and how easy it makes to share data across multiple views or even "submodules" of rather simple application. But it seems to me that it creat ... read »
Jun 19, 2013 at 9:38 PM
Directive Link, $observe, And $watch Functions Execute Inside An AngularJS Context
@Alesei, Glad you like it. Even after working with AngularJS for months, I still get a bunch of unexpected, "$digest is already in progress". So hard to debug sometimes! ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools