Reputation: 2630
I want to get "localhost" (or whatever text) inside this string:
XML-Execute-Result: <host>localhost</host>
I want a general method, like a way to reuse an expression value (like with sed in linux)
sed 's/*[0-9]$/\$&/'
Thank you very much for any reply
Upvotes: 0
Views: 119
Reputation: 6605
PS> if ($text -match "<host>(.*?)</host>") {$matches[1]}
localhost
Upvotes: 0
Reputation: 43459
$text = "XML-Execute-Result: <host>localhost</host>"
if ($text -match "\<host\>(?<host>.*?)\</host\>")
{
$myhost = $matches.host
}
Upvotes: 1