Heal Your Church WebSite


Teaching, rebuking, correcting & training in righteous web design.

Regluar Expressions Editors and Testing Apps.

McCulloch 1432 Gas Powered Chainsaw
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:

Desktop Tools:

  • 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.

Online Tutorials:

Online Testing Tools:

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.

9 Comments

  1. I’ve also found the Web site http://www.regexplib.com/ to be invaluable.

    This site has a list of regular expression patterns which can be easily copied. Mainly information is used for testing input from a user, such as making sure a date entered is a valid day of the year.

    Peace,
    +Tom

  2. I’ve not used it a whole lot myself, but I’ve heard really good things about the Regulator: http://regulator.sourceforge.net

  3. I prefer Stihl over McCullough.

  4. I just wrote about this in my blog, but I think the easiest way to do regex is to make a state diagram. Having a picture to mentally follow makes things a whole lot easier in the debug phase. Then when you go to the checker to verify, you have a clearer understanding.

  5. If you’re willing to shell out a little cash($30 US), I would recommend RegexBuddy. I literally went from clueless about regular expressions to comfortable within minutes. It also generates PHP, PERL, C# and a bunch of other types of code for you, which is neat.

    http://www.regexbuddy.com/

    Anyways, nice article as always Dean. Good luck with your switch to WordPress.

  6. Hi,

    I’ve just tested my old scripturizer for PHP, and references to multiple verses on the same book works fine for ESV on GNP’s site, as long as you use a coma ‘,’ to deliminate the verses. Multiple verses on different books would not work (like “Romans 5:8, Ephesians 2:8-9″) , as 2 separate links would be generated. Multiple verses does not currently work on Bible Gateway either as BG requires a semicolon ‘;’ between verses – but that can be easily hacked.

    I am currently updating the old PHP scripturizer code to your 1.3 code base which supports short Bible book names. And I will also wrap it up as a WordPress plugin.

    I’ll keep you updated. By this weekend I hope :)

  7. Oops. My bad. I mean Bible Gateway uses ‘;’ for parallel view, but ‘,’ works fine with verses in the same book.

  8. Glad to hear you’re pondering WordPress. I’ve been using it for about two weeks now and am thrilled.

  9. WordPress is nice, but I’ve found Textpattern to be even more awesome. Also, I’m attempting to port a Scripturizer php mod to a plugin in Textpattern (except it might require a modification to Textile, which is rather irritating.)