需要正则表达式通配符快速帮助

时间:2016-02-16 15:17:23

标签: regex powershell

尝试从字符串中删除部分网址: 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
}

谢谢!

1 个答案:

答案 0 :(得分:1)

您在星号前缺少一个点.

$Pattern = "https.*DC/"
$New = ""
$dc = [regex]::replace($dc, $pattern, "")
"We will now replace $Pattern with $New :" 
$dc
}