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.
| || || |
| || |
| || || |
Looking For A New Job?
- Part-time remote DBA needed at Bridge
- Senior Developer Wanted for International Cloud Company at Giva, Inc.
- ColdFusion Developer - jQuery, PrimeUI, ORACLE DB at ComSpec International, Inc.
- Jr. ColdFusion Developer - Full Time / Telecommuting is ok. at InterCoastal Net Designs
- CF Engineer with Big Data Hadoop experience. at Border City Media
"best gift you've given yourself in years."
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.
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.
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.
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.
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.
That's an awesome little tool. I like the way you can hover over the matches and it shows you the captured groups.
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."
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