[英]Powershell string variable substitution
I am quite familiar with bash's ability to substitute parts of strings in a regex-ish fashion using braces. 我非常熟悉bash使用花括号以正则表达式方式替换字符串部分的功能。 Eg:
例如:
a = "Hello, World!"
echo "${a/World/Nancy}"
The above will print "Hello, Nancy!" 上面将显示“你好,南希!” Does powershell have the ability to do substring-subtitution in this way, or is there an equivalent alternative?
powershell是否有能力以这种方式进行子字符串替换,或者有等效的替代方法?
The -replace
operator (supports regex): -replace
运算符(支持正则表达式):
$a = "Hello, World!"
$a -replace "World","Nancy"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.