Debuggex – a New Regular Expression Debugging Tool
March 6, 2013 8:52 pm 4 CommentsMost people, beginners and professionals alike find regular expressions sometimes confusing, perhaps because developers do not really use this in their everyday development. As of the time this post was written, there were about 53000 questions in stackoverflow concerning regular expressions in some repect; surely this points out how many people are having some sort of problem concerning regular expressions.
Sure there are various tools such as php substr function that would help with simple pattern matching, however for more advanced matching, nothing can beat regular expressions. Unfortunately as I mentioned before a lot of people are having problems, this is where tools like Debuggex come in handy.
Debuggex is a new regular expression debugging tool. It’s a javascript web application which should run on any modern browser. Therefore you can access this anywhere. Today we’ll take a look at the advantages that this tool offer as well as areas where it can improve.
It is important to note that Debuggex is still in beta version, therefore I’m sure there will be more improvements to come.
Advantages
Visual Representation!
Debuggex shows the visual representation of a string of regular expressions, this is very important if you are a visual person. So far this is the only regular expression tool that offers this.
For example, if I were to put this regular expression in: ^[0-9]*(,)[0-9]*(\.)[0-9]*; unless you deal with regular expressions every single day it will take you at least a couple of seconds to get what it is trying to do. This is where the visual representation comes into play.
Thanks to the visual representation we now know were is our group and what each segment will try to match.
Match testing
The ability to enter a test string AND slide through the regular expression string to follow the matched portion is very valuable. This is almost like stepping into a function in your regular software debugging tool.
Thanks to the segment slider we are able to see from this example, that the rule “[0-9]*” does match the any number after the “,”.
Random Matches
This little section is useful to see examples of strings that can be matched with the current regular expression string that you are currently writing. Simple, but useful.
Things that can be improved
Like I said previously, this tool is a beta, therefore some things that I mentioned here might already be in their development pipeline. Nevertheless here are things that can be improved (aka. wishlist).
Replace Simulation
So far this tool does a good job representing searching steps of a regular expression. If it is able to provide a test string and simulate replacing portions matched by the regular expression, it would be great. This is simply because a lot of people use regular expression to do search and replace. For example: in a screen scraper, sometimes we want to remove the domain from a link, so that something like “www.codingepiphany.com/debugex/” becomes “/debugex/”.
Suggested Rules
This might be asking a lot as I know it can be technically difficult. But hey, this is a wishlist after all. Perhaps when the string does not match, the tool can then give out some suggestions of regular expressions rule that might help.
More detailed debugging output
Another tool that I found called RegexBuddy is able to provide very detailed debugging messages. Although RegexBuddy is not a web application like this perhaps there is something to learn from their detailed output.
Conclusion
Debuggex is one of a kind regular expression debugging tool, I have not found any other tool as clean and simple as this one. Definitely worth a try and it’s a free tool too. This application has a very good chance of becoming the JsFiddle of regular expression world.
So what are you waiting for, just go to Debuggex.com and try some regular expressions.
Tags: coding, javascript, regular expressionCategorised in: Review, Software Development, Tools