Using the replace operator on a string that has quotes powershell Using the replace operator on a string that has quotes powershell powershell powershell

Using the replace operator on a string that has quotes powershell


You can either escape the nested double quotes like so `" or better yet, use single quotes for quoting of the string then you won't need to escape the double quotes e.g.:

'this string "has" quotes'

Note: with single quotes you won't get variable expansion in a string.


You can Grave (the tilde key) double quotation marks as an escape character. You can do this to any special character in a string.

e.g.

$a = "This String `"Has`" Quotes"$a = $a.replace("This String `"Has`" Quotes","this string won't have quotes. ")