Getting Your Feet Wet with Regular Expressions
Wrapping your head around regular expressions is a daunting task for a programmer. Many times there is a tendency to just avoid the issue and write lots of code to work your way around an issue that could be easily solved with one line. You could always go out and buy one of the many books on the subject, but I am going to focus on teaching yourself online.
The first thing you'll need is a way to test out your work. I am a big fan of the Regex Widget for the dashboard by Rob Rohan.
This little widget will provide an easy interface for testing simple expressions with immediate feedback. On occassion I've also used BBEdit's built in regex ability when I've wanted to keep track of several versions of an expression at once.
The next hurdle is getting the basics down. A really great site for this is regular-expressions.info. Reading this information, and then re-reading this information, and then referring back to it when writing your expressions will definitely get you started.
The final step is beginning to use regular expressions in your projects in a lot of different situations. Instead of running out and using someone else's pre-built expression for validating e-mails try and write it yourself first and then go and compare it to see what you missed. Once you get the hang of it the power becomes more and more apparent, just don't let it go to your head.
Comments
Post new comment