尝试从字符串中删除部分网址: https://test.com:443/api/DC/XYZ
预期结果: XYZ
尝试:
$Pattern = "https*DC/"
$New = ""
$dc = [regex]::replace($dc, $pattern, "")
"We will now replace $Pattern with $New :"
$dc
}
谢谢!
答案 0 :(得分:1)
您在星号前缺少一个点.
:
$Pattern = "https.*DC/"
$New = ""
$dc = [regex]::replace($dc, $pattern, "")
"We will now replace $Pattern with $New :"
$dc
}