包含管道字符的字符串 - 如何避免它们被误认为逻辑 OR


$word = '{Quit|Discontinue|Stop|Cease|Give Up}'
$htmltitle1 = $word -replace  '{Quit|Discontinue|Stop|Cease|Give Up}', 'Give Up' 

$htmltitle 1

Give Up|Give Up|Give Up|Give Up|Give Up

如何强制 powershell 将要替换的文本作为确切的字符串而不是逻辑 OR?

它应该只是:

Give Up

谢谢

$htmltitle1 = $word -replace [regex]::escape('{Quit|Discontinue|Stop|Cease|Give Up}'), 'Give Up'