Reputation: 145
I am quite familiar with bash's ability to substitute parts of strings in a regex-ish fashion using braces. E.g.:
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?
Upvotes: 1
Views: 1751
Reputation: 4069
The -replace
operator (supports regex):
$a = "Hello, World!"
$a -replace "World","Nancy"
Upvotes: 4