powershell replace function code example
Example: 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!