Thanks so much for your excellent examples! You clearly understand regex deeply, and are therefore my new best friend.

Originally Posted By: canuckInOR
This is fairly well formed. Maybe something like:


I forgot to say that I can't guarantee that format. For instance, some of the functions might not be [Test] functions (they might be helper functions), or they might not have the <summary>. So your first two examples won't work.

Your third example is the exact thing I wanted to try. I had tried some variants of it before, but I couldn't get the syntax correct. Your syntax was correct except for one trick:
Code:
'private\' is not recognized as an internal or external command, operable program or batch file.

Simple enough fix: Surrounding your query in double quotes instead of single quotes worked as you intended (double quotes are required at the DOS command line to make it ignore the | symbol as a pipe-to-another-command syntax).

So when I did that, it worked! It showed the entire function. But it has another issue to solve:

In addition to the function I want to scan, it also returns the introductory lines of the next function (the HTML comments and the test decorators). I want it to *not* include those lines, I want it to stop at the closing curlybrace just BEFORE those lines. I don't know how to do the regex syntax to pull off that trick. Though I think it should theoretically be doable because I don't think it requires counting and keeping track of curly brace counts. Do you know how to do that?

Something else about your example: the function I'm scanning might, in some cases, be the very last function in the file. In that case, your example gets the error message:
Code:
fatal: -L parameter '\(public\|private\|protected\|internal\|sealed\)' starting at line 638: No match

What is the syntax to work around that so that it gets me to the end of the file even if it can't find the (public|private|etc.)?

I also thought of a way to make it more robust. The functions I'm scanning should always be an Nunit test, and by definition, nunit tests must be declared "public void", so I could include that before the name of the function in the first part of the regex so that I can be certain I'm finding the actual test function.
_________________________
Tony Fabris