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 »
78 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 »
10,640 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 »
10,640 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 »
19 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 »
10,640 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
InVision App - Prototyping Made Beautiful With Prototyping Tools Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
Feb 10, 2012 at 7:21 PM
jQuery AJAX Strips Script Tags And Inserts Them After Parent-Most Elements
Update! Instead of $(eval(options.insertAfter)).after(data['insertData']); I now use: var ajaxNode = document.createElement('span'); var parent = $(eval(options.insertAfter))[0].parentNode; ... read »
Feb 10, 2012 at 6:18 PM
jQuery AJAX Strips Script Tags And Inserts Them After Parent-Most Elements
encountered this same, what I consider, jQuery bug last week. I'm building a site in which I load some content via AJAX. This content contains Linkedin share button placeholders which Linkedin API ne ... read »
Feb 10, 2012 at 11:30 AM
Cross-Origin Resource Sharing (CORS) AJAX Requests Between jQuery And Node.js
After you understand the concepts here, this is an awesome cheatsheet for enabling CORS in just about anything http://enable-cors.org/ ... read »
JM
Feb 10, 2012 at 9:10 AM
My Safari Browser SQLite Database Hello World Example
@Amy, Here is a very good tutorial on how to use JOIN: http://www.sqltutorial.org/sqljoin-innerjoin.aspx ... read »
Feb 10, 2012 at 4:42 AM
Building A Twitter-Inspired RESTful API Architecture In ColdFusion
This is great, very useful Ben. I spotted a small typo in the api.cgm listing: <cfthrow type="Unauthroized" /> Cheers Stefan ... read »
Feb 9, 2012 at 10:35 PM
CFDirectory Filtering Uses Pipe Character For Multiple Filters (Thanks Steve Withington)
I was wondering if there would be a filter you could apply so that you got everything but what you included in the filter. As in show me all docs that are not a .pdf. ... read »
Feb 9, 2012 at 10:29 PM
Learning ColdFusion 9: Application-Specific Data Sources
@Ben, No offence, but if people were really wanting advanced features they would be using a platform like ASP.NET MVC. CFML is so structurally compromised as a tag-based scripting language that ... read »
Feb 9, 2012 at 10:03 PM
Subversion - Cleanup Failed To Process The Following Paths
@Leviaguirre, do you still have problems with this? ... read »