tags:

views:

58

answers:

2

I'm very bad with regular expressions and cannot find how to write the pattern I'm looking for. I'm trying to parse the output from Visual Studio looking for errors. I'd like to exclude things like...

5>projname - 0 error(s), 0 warning(s)

but grab lines like 6>codeFile.cpp(1282): error: 'TEST_ITEM' was not declared in this scope

I know for this specific example it'd be very easy to test against error: but it's possible for error to have whitespace on any side. I need essentially a pattern that will match everything except "0 error(s)". Any help or suggestions would be great!

Thanks

+3  A: 

I would recommend Expresso very good tool for writing and learning regular expression... But based on your code this expression should work:

^.*\s0\serror\(s\),\s0\swarning\(s\)\Z

If you had a few more example lines of the test I might be able to write a better expression...

J.13.L
+1 for great tool.
Steven Sudit
Thank you very much! I actually planned on writing my own tool over the weekend and sitting down to play with regular expressions. I needed a solution for a project at work so this was a big help, thanks!
A: 

what language are you using to parse the output from Visual Studio? in Perl, you could do something like

$str !~ /\b0\serror\(s\)\b/;
Cliff