Using Powershell I would like to extract a value from text file that is in between two lines that match a pattern.
I'm trying to match 3 lines, 1st & 3rd will always be the same:
1st: ' 1'
2nd: trying to read... always 2-4 characters
3rd: ' 40'
There are multiple occasions where line 1&3 should match this.
I tried with bellow code.
$aa=Get-Content $filename1 -Raw
$aaa=$aa |Where-Object { ( $_ -match '(.\s1)(?:\r\n|[\r\n])*(?:\r\n|[\r\n])(\s40)') }
$aaa
I get too much output...maybe it's matching just 1st and 3rd line and many lines in between.