Regular Expression Mayhem

via <a href="https://www.flickr.com/photos/sirexkat/1128067974" target="_blank">sirexkat at Fickr</a>

I have never really been comfortable with regular expressions. While I can look at code in a programming language I have little or no experience with and understand what it is trying to accomplish, regular expressions has never been that way for me. Usually, there is a lot of guess work and trial and error to figure out how to get things to sorta-kinda work, but rarely any confidence in it. With some freelance work I've been doing recently, regular expressions have become a necessity in a few cases. I've found some tools to make the work easier and give me confidence the expressions work as intended.

Like any language that I don't use regularly, remembering the syntax and reserved characters (metacharacters) is not something that I can recall quickly. In the past, I found myself wading through tutorials to find what I was looking for resulting in a time consuming search. I recently discovered a cheat sheet for regular expressions that has greatly helped me to find what I'm looking for quickly.

When coding and testing regular expressions I have often taken a trial and error approach. Well, more an exponential trial and error approach since I often feel like I'm fumbling in the dark to nail down the expression I'm trying to create. Having to rerun my code to test small changes in my expression is both very annoying and very time consuming. Another really awesome tool is "Regular Expressions 101". You can provide both your expression and a test string and instantly see the results. It will update in real-time with the results of the expression as you change the expression or the test string. It allows me to test expression that I'm writing on the fly and quickly figure out where I'm going wrong.

I truly am my own worst critic, but it has its benefits. I know where I can improve and given the opportunity I seek out the tools to do so. These two have been of frequent use by me in my recent project.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.