How To: Overcome Being Regular Expression Challenged

I had never really learned regular expressions. Oh sure, I could use * and ? as well as the next guy, but throw [0-9]+ at me and I had no idea what it meant. That is, until the last year or so. Regular expressions can be very helpful in pattern matching against file names or user input and I dislike having gaps in the overall toolset of things I’m comfortable using.
So I set out to correct it. I’m still pretty ham-handed when it comes to typing in a regular expressions and I end up having to consult cheatsheets in order to remember the syntax to do a lot of things, but I discovered online tools and websites that helped me overcome the gap in my knowledge. Here are my favorites:

  • txt2re: headache relief for programmers – This lets you input a piece of text you want to match against using a regular expression and it displays different expressions you could use depending upon which parts you want to match against. It can give you a quick start on matching even if you aren’t yet very regex savvy.
  • RegEx: online regular expression testing – This is the other handy part of the equation. Here you can input several items of sample text and a regular expression you wish to test. Hit the test button and it will show you which test text matched, what parts were matched, etc. It’s somewhat Java oriented but might be as useful for any language with fairly standard regex syntax. I’ve found it very helpful for iterative development of complicated regular expressions.
  • Regular Expression Library – A library of already crafted regular expressions (with various levels of complexity and robustness) to validate things like email addresses and telephone numbers.
  • Regular Expression Tutorial – A tutorial capable of teaching you enough to be dangerous in a fairly short time. Good info and it’s not intimidating.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s