views:

107

answers:

2

Are there tools out there to measure code coverage of regexes? A tool that given a regex and a list of input strings, tells you which parts of the regex are exercised, with measures analogous to statement coverage, branch coverage, condition coverage, etc.

I don't care much what language or environment it runs in.

(Update: after some more thought, I was realizing that it's pretty easy to start with a regex and generate various exemplars. There are some tools out there to do this: http://research.microsoft.com/en-us/projects/rex/ , http://code.google.com/p/xeger/ ). They don't seem to try to get full coverage, though; they just take random paths through the DFA.)

+1  A: 

Regex Buddy - It allows you to open a testfile and run it against your regex and show you matches etc. It's pretty cheap considering how useful it is.

hydrogen
I was going to suggest that too, but for debugging, RegexBuddy gives you a "merely" visual aid (which is perfect for debugging a regex), and since those debug trees can be thousands and thousands of lines long (and do not measure anything except the overall steps necessary to match or fail), I'm not sure that's what he needs. Definitely try it, though.
Tim Pietzcker
It looks like an interesting tool, but yeah, probably not exactly what I meant. I'll come back to it if I don't find any spot-on answers.
Steven Ourada
It's probably the sort of tool you want lying around if you're doing anything complex with regexes.
Tikhon Jelvis
+1  A: 

Try program "The Regex Coach"

watbywbarif
Thanks for the pointer. It's an interesting tool, but doesn't do coverage, specifically, as far as I can see on the site.
Steven Ourada