How to test your regular expression

Of course, the ultimate tool is RegexBuddy by Jan Goyvaerts. I personally don’t have it at the moment, but I surely need to get it soon. It supports various languages, gives you detailed explanation on each part, you can step through the matching process …

But if you use regex not often and do only small ones, you should be fine with free online regular expression testers. And it is important that you test your regex, extract use cases from your real data and add also test data that you don’t want to match!

Online regex testers are a great help while developing a regular expression. As long as you do not want to use features they don’t support, they visualize your match and show you the content of the capturing groups instantly.

Critical features, you should test in your real language, are mainly lookbehind assertions and Unicode  features like Unicode properties.

My favourites are

Regexr is based on ActionScript 3, that means it implements regex after the ECMA-262 standard.  See for more info. (I am not sure if the standard has changed or Regexr has changed, because Regexr supports simple look behind assertions, but ECMA-262 does not).

Matches are highlighted and the content of the capturing groups is shown when the mouse hovers over the match, it also allows to test replacements and allows to create permalinks to your tested regex (to share it easily on SO ;))

Rubular is based on Ruby.   See for more info. Matches are highlighted and the matches and the content of the according capturing groups are shown in a list. The regex is processed on a server, therefore the result is not shown instantly but quite quick the most of the time. It allows also to create permalinks to your tested regex

Other online testers are (I use them not often, but try them to find your personal favorite)

And at last, this is not tool for testing, you can give it a regex and it tells you what this is doing:

2 responses to “How to test your regular expression”

  1. I love your blog.. very nice colors & theme. Did you make this website yourself or did you hire someone to do
    it for you? Plz answer back as I’m looking to construct my own blog and would like to know where u got this from. thanks

    • Thanks for your nice comment. I did this blog myself. The theme is called “Twenty Eleven” (in Version 1.4 at the moment). It came with my wordpress installation, so I assume it is standard. I haven’t changed much to the layout, but only due to a lack of time.
      When you have your blog up and running, please post a link here, I would be interested to read it!

Leave a Reply

Your email address will not be published. Required fields are marked *