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

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details 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: The rating for this expression. Mike Stancombe
   Displaying page 1 of 1 pages; Items 1 to 1

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