Replace Text in String

PowerShell has a replace method and a -replace operator.

-replace Operator

The -replace operator, like the -match operator uses regular expressions (Regex) to find the part of the string to replace. That means that the Regex operators will interpret special characters that might be found in a password as a Regex operator rather than as a literal character.

.replace Method

PS > "Hello World".Replace("World", "PowerShell") Hello PowerShell

Links