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

$html标题1

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

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

它应该只是:

Give Up

谢谢

4

1 回答 1

4
$htmltitle1 = $word -replace [regex]::escape('{Quit|Discontinue|Stop|Cease|Give Up}'), 'Give Up'
于 2013-06-29T14:16:35.623 回答