Title |
Test
Find
Pattern Title
|
Expression |
(at\s)(?<fullClassName>.+)(\.)(?<methodName>[^\.]*)(\()(?<parameters>[^\)]*)(\))((\sin\s)(?<fileName>.+)(:line )(?<lineNumber>[\d]*))? |
Description |
Just a simple regExp to parse the stack trace. Developed when using the exception block from MS, coz they only showed the stack all bunched together. Could be used as follows:
[C#]
string regExParams = @"(at\s)(?<fullClassName>.+)(\.)(?<methodName>[^\.]*)(\()(?<parameters>[^\)]*)(\))((\sin\s)(?<fileName>.+)(:line )(?<lineNumber>[\d]*))?";
Regex re = new System.Text.RegularExpressions.Regex(regExParams,RegexOptions.Compiled);
MatchCollection mtc;
mtc = re.Matches(System.Environment.StackTrace);
foreach(Match mt in mtc)
{
MessageBox.Show(mt.Result("${fullClassName}"));
MessageBox.Show(mt.Result("${methodName}"));
MessageBox.Show(mt.Result("${parameters}"));
MessageBox.Show(mt.Result("${fileName}"));
MessageBox.Show(mt.Result("${lineNumber}"));
}
Seems to work well, but use at your own peril!!
Feel free to use and enhance (there's probably a lot that could be done, like getting parameters individually(?), etc) |
Matches |
at System.IO.__Error.WinIOError(Int32 errorCode, String str) | at ExceptionManagementQuickStartSampl |
Non-Matches |
ExceptionManagementQuickStartSamples.Form1.DoLogon(String userName, String password) in c:\program f |
Author |
Rating:
Mike Stancombe
|
Source |
me |
Your Rating |
|
Title: Stack Trace Parser
Name: Mike
Date: 7/9/2003 8:17:06 PM
Comment:
Hmm.. I think the page screwed with the expression.. Hope it looks right when this is saved.. Damn ASP..