On Feb 17, 1:14 am, pjo <gu...@xxxxxx-email.com> wrote:
Quote:
> Hi!
> I have an html file which has several instances of the same string
> pattern "ABCDEF".
>
> $a = Select-String -Path d:\work\test.html -pattern "ABCDEF"
>
> and find the line number of the last instance of the pattern "ABCDEF"
> by
>
> $c = $a[$a.Length -1].ToString().Split(":")[2]
>
> $c contains the line number.
>
> How could I point to the next line number which is $c + 1 and retrieve
> the string of the next line to a varible ?
>
> Thanks in advance.
>
> pjo
>
> --
> pjohttp://www.techtalkz.com- Technology and Computer Troubleshooting Forums
If the line number is $c, then try this:
(get-content test.html)[$c]
If you only interested in the line after the last "ABCDEF" in file
test.html, try this:
get-content test.html | foreach { $prev = "" } { if ($prev -match
"ABCDEF") { $result = $_ }; $prev = $_ }
$result should hold the value that you want.
--
Kam-Hung Soh <a href="http://kamhungsoh.com/blog">Software Salariman</
a>