Regular expressions are like a chain saw … a gas powered chain saw. At first, you’re deathly afraid of even touching it. When you do fire one up for the first time, it’s only after you’ve dressed yourself like a hockey goalie and have your spouse waiting just outside of your roped-off area with his or her their finger on the 911 speed dial button.
Once you realize that if you practice some common sense, that is you take time to think through what you’re trying to do first, regular expressions become your favorite power tool – just like your chain saw.
For example, now that I’m pondering a move to WordPress, I’ve got to port Scripturizer from Perl to PHP. Scott Yang has already done much of the work, but the regex needs to be expanded to include multiple references, e.g. Romans 10:9-10, 12:1-2 or Matthew 5:6-7, 9-12.
Debugging something like this can become incredibly frustrating using the code and test method. Not so much since I have both Perl and PHP installed on my local PC. Still, having tools to help construct, visualize and debug your regular expressions can help reveal hidden bugs, catch typos that snuck past your bleary gaze, and/or teach you how to use your chain saw – I mean regex – without cutting your foot clean off.
So here are some tools, tutorials and testers I found:
- Kiki – a free environment for regular expression testing (ferret). It allows you to write regexes and test them against a sample text, providing extensive output about the results.
- For those of you who love Linux: the KDE Regular Expression Editor
- Expresso – A tool chest for building and testing regular expressions for Microsoft Windows .NET.
- Like PHP but hate regular expressions? Try the RegExpEditor module with PHPEdit.
- RegEx Coach – don’t let the plain-jane website fool you out of using this Window-based tool.
- A Tao of Regular Expressions – how regex is used by different languages/editors
- Regular Expression Tutorial by Regular-Expressions.info
- An Introduction to Regular Expression with VBScript by 4Guys.
- The Code Project – An Introduction to Regular Expressions
Online Testing Tools:
- Quanetics – Regular Expression Tester – includes useful cheat sheet
- Simple Regular Expression Tester by WebDevTips.
- Bite Size – Online Regular Expression Syntax Checker
Leave a comment if you have a favorite not on the lists. Or if you have tried one of the above cool regex tools and tutorials, let us know what you think.