这是针对我刚才的问题:的PowerShell:报价-replace&变量
PowerShell: -replace, regex and ($) dollar sign woes
我的问题是:为什么这2行代码有不同的输出:
'abc' -replace 'a(\w)', '$1'
'abc' -replace 'a(\w)', "$1"
根据以下两篇文章,为什么单引号中的变量'$ 1'不能用作文字串?单引号中的所有内容都应该被视为文本字符串,对吗?
http://www.computerperformance.co.uk/powershell/powershell_quotes.htm
http://blogs.msdn.com/b/powershell/archive/2006/07/15/variable-expansion-in-strings-and-herestrings.aspx
(灯光熄灭)马恩,谢谢。很好解释。 – Vippy 2012-02-23 23:31:35