I'm trying to get full error with line from following example:
date time somemethod EXC somenumber sometext R:System.NullReferenceException: Object reference not set to an instance of an object.
at sometext in somepath .cs:line somenumber System.NullReferenceException: Object reference not set to an instance of an object.
at sometext in Somepath .cs:line somenumber
From that, I'd like to get everything after EXC up to cs:line somenumber.
01/01/01 date (mode) (status) (somenumber) (name+error), right here there's usually a new line which continues with error message, which ends on characters cs:line (number).
I managed to get error message as it always starts with EXC (so regex is EXC .*, however im unable to get full message with code. I have access to PowerShell 2.0 only, I'm using following formula:
$Filecontent = [io.file]::Readalltext("path to file")
$filecontent | select-string 'EXC .*' -allmatches |
foreach {$_.Matches} | Foreach {$_.Value} > errors.txt
What I need is to get full error with line number but I have problem with proper regular expression. I do not care about the date,time,mode, regex should get EXC status and take full message with line.
After using regex 'EXC .*\n.*cs:line [0-9]{0,99}' it finds me those messages that after one line are finished with error message, however, sometimes theres more next lines that I'd like to capture as well. Any ideas?