RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

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: Not yet rated. Mike Stancombe
Source me
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

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..


Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials