Frank
Frank

Reputation: 45

get only a string from foreach/select result

Select-String -Path 'C:\Users\Public\Desktop\hs-source.txt' -list  '\bhttp\:\/\/www\.hs\-scene\.to\/wbb4\/index\.php\/Thread\/(?:(?!Neuerscheinungen)(?:.|\n))*Neuerscheinungen-((?:Jan(?:uar)?|Feb(?:ruar)?|Mär(?:z)?|Apr(?:il)?|Mai|Jun(?:i)?|Jul(?:i)?|Aug(?:ust)?|Sep(?:tember)?|Sept|Okt(?:ober)?|Nov(?:ember)?|Dez(?:ember)?))(-20\d{2})'  | foreach-object  {$_.matches} | select value 

give me this result:

Value
----                                                                      
http://www.hs-scene.to/wbb4/index.php/Thread/42042-H%C3%B6rbuch-Neuerscheinungen-August-2015 

how can i get only the link, without value and the strokes? I want to use the link in the next part of my script. Thanks for your answers.

Upvotes: 2

Views: 86

Answers (1)

arco444
arco444

Reputation: 22821

Change the final pipe command to:

| select -ExpandProperty value

Otherwise value remains a property of the object, it just happens it's the only property you're selecting. You would need to access it with $obj.value without the -ExpandProperty switch

Upvotes: 6

Related Questions