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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -