powershell - RegEx Match whole line with first occurrence from the bottom of the file, upwards -


i'm trying parse file error codes. first occurrence bottom of file returned.

so far, i've got regex searching error code numbers, , returns whole line multiline option, returns lines in file, not last one.

^.*?\b(639|640|460|458|664|148)\b.*$ 

i'm using powershell, if have example using powershell - great.

thank you.

assuming regex correct matching on line should able this:

$pattern = '^.*?\b(639|640|460|458|664|148)\b.*$' $content = get-content c:\somefile.txt ($i = $content.length - 1; $i -ge 0; $i--) {     if ($content[$i] -match $pattern) {         $matches[1]         break     } } 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -