Working with Regular Expressions

April 18, 2008 – 11:38 am Tags: ,

Regular Expressions - you either love them or hate them, and usually when you hate them, you just haven’t spent enough time trying to learn them! :)

They are incredibly useful, but they can often be difficult to build and test. I have previously mentioned a great tool called RegexBuddy, which is a great help.

However, being a Windows application, you might not always have your PC with it installed around. I’ve often found myself stranded, looking for a quick way to write and test a regex.

I decided to fix this problem once and for all: Say hello to the JavaScript Regex Tester!

The obvious solution - a web-based one

The solution to the problem posed by not having a regex tool with you is to make a regex tool which is always (or at least most of the time) accessible… Thus make it a web application!

I decided to write some simple JavaScript code to run and test regular expressions and display the resulting match and submatches. The result is the JavaScript Regex Tester.

The tester does not work without JavaScript enabled, which could be thought of a problem for users on mobile devices… but how often do you find yourself writing code with your phone? I’d say not very often - more like “never”.

Because it’s solely JS based, it’s also faster than doing round-trips to the server to fetch results with Ajax or such, so it’s nicer to use.

  1. 4 Responses to “Working with Regular Expressions”

  2. RegexPal - http://regexpal.com/

    By ZX on Apr 19, 2008

  3. Biggest problem with regex is that there are so many different flavors..
    Last week I had my client side form validation fail because I used some specific PHP modifier in the javascript… sigh.

    By MrOxiMoron on Apr 20, 2008

  4. Javascript has a limited RegEx functionality. For example, it can’t do lookbehinds.

    BTW, check out my card trick:
    http://www.lonniebest.com/CardTrick/

    By Lonnie Best on Apr 25, 2008

  5. best RegEx debugger/ evaluator (challenging even the Doctor’s mighty Lisp-based Coach!).
    What’s even more amazing is the speed, with which it processes expressions, and via http. impressive, IMHO.

    http://www.rexv.org/

    By RouqseTar on Apr 26, 2008

Post a Comment