Skip to main content
Skip table of contents

new--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

CODE
PS > "Hello World".Replace("World", "PowerShell")
Hello PowerShell
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.