I want to replace "$" from a string in PowerShell. I am trying this:
PS> $vars
abcd$
PS> $vars -replace "`$"
abcd$
How to replace the "$" in the string?
I want to replace "$" from a string in PowerShell. I am trying this:
PS> $vars
abcd$
PS> $vars -replace "`$"
abcd$
How to replace the "$" in the string?
The -replace operator uses regular expressions for string matching thus you have to escape the dolar using a backslash:
$vars -replace "\$"
Cheers!