1

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?

1

1 Answer 1

4

The -replace operator (supports regex):

$a = "Hello, World!"
$a -replace "World","Nancy"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.