$strText = '<httpHandlers>
<remove verb="GET,HEAD,POST" path="*" />
other content ....
</httpHandlers>
$Pattern = '<remove verb="GET,HEAD,POST" path="*" />'
$New ='<remove verb="GET,HEAD,POST" path="*" NEW CONTENT ADDED />'
$strReplace = [regex]::replace($strText, $pattern, $New)`
似乎不起作用
答案 0 :(得分:1)
$strText = '<httpHandlers>
<remove verb="GET,HEAD,POST" path="*" />
other content ....
</httpHandlers>'
$Pattern = [regex]::escape('<remove verb="GET,HEAD,POST" path="*" />')
$New ='<remove verb="GET,HEAD,POST" path="*" NEW CONTENT ADDED />'
$strReplace = [regex]::replace($strText, $pattern, $New)
$strReplace
$strText
缺少报价[regex]::escape
来解释它。