Regular expressions are a cool thing—until you wrote your first expression with more than a dozen of characters. Then, regular expressions basically become a mess: just after you wrote expression, you likely already forgot what the initial [^[\]] meant and why you needed .*?(\w*). It particularly becomes nasty, when there is a bug in the expression and you can’t find it. That was what actually happened to us. We spent an afternoon and night debugging a long, but not too complicated expression just to locate a simple bug. It was after that encounter that we decided to do something about it. We developed RegViz, a tool to visually debug regular expressions. The requirements were clear quite soon: The tool should
- improve the readability of regular expressions,
- help to debug and test the expression, and
- be easy to use without requiring any explanation.
As we could not simply change the syntax of regular expressions, the tool needed to be build on top of the already existing regular expression infrastructure. In the following, I briefly introduce RegViz and its features, but also want to give an overview of alternative tools—some of the them had been around before, others were developed in parallel to RegViz. As RegViz is a quite visual approach, I focus more on tools that include a visualization of some sort or at least advanced syntax highlighting. Although the problem is far from being solved, I think the support for handling regular expressions made a big leap recently.
RegexBuddy is probably the most established tool presented here. Unlike the others, it is not a free web application, but a commercial desktop program. The user interface looks a bit complicated, but provides many helpful views and feature providing deep support for writing and debugging regular expressions. For instance, one view explains the regular expression in natural language text, another shows the stepwise parsing process in detail. Often very practical, matched strings can be replaced by other strings or variants of the match. RegexBuddy is extremely versatile as it supports more than a dozen different dialects of regular expressions.
regular expressions 101
- Refiddle – http://refiddle.com/
- regexpal – http://regexpal.com/
- REGEXPER – http://www.regexper.com/
- RegExpress – http://regexpress.io/
- Regular expression visualizer – http://regexvisualizer.apphb.com/
- Regulex – http://jex.im/regulex/
- Textpression – http://www.textpression.com/
- txt2re – http://www.txt2re.com/
and many more.