$word = '{Quit|Discontinue|Stop|Cease|Give Up}'
$htmltitle1 = $word -replace '{Quit|Discontinue|Stop|Cease|Give Up}', 'Give Up'
$ htmltitle1
Give Up|Give Up|Give Up|Give Up|Give Up
如何强制powershell将文本替换为精确字符串而不是逻辑OR?
应该是:
Give Up
感谢
答案 0 :(得分:4)
$htmltitle1 = $word -replace [regex]::escape('{Quit|Discontinue|Stop|Cease|Give Up}'), 'Give Up'