Debuggex - A visual regex debugging tool

Yesterday for a project at work I needed to develop some regexes to parse a bunch of strings like:

Dmax <= 30Gy(35.1Gy)
Dmin >= 100.4cGy (99Gy)
D90% > 20.1 Gy
V2Gy > 80.0% (75%)
V10Gy < 100cc

and so on. I was having a bit of trouble getting the regex to match up all the different cases (as everyone knows, regexs can be a bit tricky to get right :). I remembered reading something on Hacker News a couple of days ago about a visual regex debugger so I decided to give it a shot.

This tool rocks.

It displays a visual flow of how the current regex is matching, shows you which part of your test string is currently matching and a really cool feature is that it will generate random matches to the current regex. If you're interested in an example, here's my first pass at parsing the "D" strings above. The actual Python re that I used looks slightly different:


because I used named groups and lowercased the string before matching but Debuggex made it a snap to get to this point.

Check out Debuggex next time you are working on a tricky regex.

comments powered by Disqus