Answers for "powershell string replace"

2

powershell string replace

# Using the replace function (case sensitive)
$str = "Hello world!"
$str.replace("world", "Mars")
# Hello Mars!

# Using the replace operator (case insensitive, allows RegEx)
$str = "Hello world!"
$str -replace "world", "Earth"
# Hello Earth!
Posted by: Guest on May-05-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language