0

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

4

2 回答 2

1
$text = "XML-Execute-Result: <host>localhost</host>"
if ($text -match "\<host\>(?<host>.*?)\</host\>")
{
    $myhost = $matches.host
}
于 2013-09-09T07:01:28.773 回答
0
PS> if ($text -match "<host>(.*?)</host>") {$matches[1]}
localhost
于 2013-09-09T14:06:35.790 回答