A true regex tester

How often have you been bitten by a regex? Here's how the story usually goes.

Two months ago, you spent 20 minutes crafting a regex. Today, you realize it has a bug and begin fixing it. Except that it now reminds you more of hi­ero­glyph­ics:


And there aren't any unit tests, because you were nearing a deadline, and writing good unit tests for regular ex­pres­sions is more tedious than most unit tests. Now you have to spend another 20 minutes figuring out what the regex does before fixing it. You finally fix it and push it to production, only to realize that there was a case that used to work and it doesn't anymore. Sound familiar?

Enter Debuggex unit tests. We tried to make it as effortless as possible to add strong unit tests for your ex­pres­sions. Here's how they work:

  1. Click "Add a unit test". Enter a string that you are testing a regex against. If you're lazy, you can click 'Suggest' and Debuggex will come up with a test case for you.

  2. Hover over the matches in the unit test. If all the matches and subgroups look like what you want to extract, click "This looks right". Otherwise click "This looks wrong".

That's it! Whenever you change your regex, all unit tests will be run to make sure they still pass. For a "right" test, Debuggex will make sure all the matches and subgroups are the same. For a "wrong" test, Debuggex will make sure at least one of the matches or subgroups differs. This keeps your regex backwards-compatible with previous versions, so you don't introduce new bugs as you fix old ones. The unit tests also serve as examples for when you return to your regex and have no idea what it does.

Debuggex is a regex tester in the very literal sense. We hope this helps you build a good workflow around working with regular ex­pres­sions.

As always, we love feedback!

A composable regex repository »