Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Getting a piece of information from a complex file

$
0
0

Hi,

wonder if someone can point me in the right direction on this one?...

I have been using invoke-webrequest to get a complex page into a text file. Rightly or wrongly I have decided that once I have the text in a file I am more confident I can do "something" with it.

What I am trying to do is find some text in the file and put into a variable. However the bit I want will change. However the text in front of it does not. So using "select-string" I have found the text before... But I am trying to understand if I can then grab something after what I have selected?

I thought about perhaps reading the whole text into array perhaps but not sure how.. I was thinking of combining this with -split "" to get every single word in the file and then loop through it until I find the text and then use the next piece of text after it..

To explain better (not the actual example)... Say my text file contains the following -

sdsdsd rubbish ksfj ksd tubb rubbish sdjjd dsa sd dsds dasdd dsadd dasdda The result is 5

I am after 5 and have found "The result is "

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles