[英]Get certain text in string powershell
我想在此字符串中獲取“ localhost”(或任何文本):
XML-Execute-Result: <host>localhost</host>
我想要一個通用方法,例如一種重用表達式值的方法(例如linux中的sed)
sed 's/*[0-9]$/\$&/'
非常感謝您的回復
$text = "XML-Execute-Result: <host>localhost</host>"
if ($text -match "\<host\>(?<host>.*?)\</host\>")
{
$myhost = $matches.host
}
PS> if ($text -match "<host>(.*?)</host>") {$matches[1]}
localhost
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.