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

2 Answers 2

1
$text = "XML-Execute-Result: <host>localhost</host>"
if ($text -match "\<host\>(?<host>.*?)\</host\>")
{
    $myhost = $matches.host
}
Sign up to request clarification or add additional context in comments.

1 Comment

Very nice. Thank you very much :)
0
PS> if ($text -match "<host>(.*?)</host>") {$matches[1]}
localhost

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.