Using the replace operator on a string that has quotes powershell

末鹿安然 提交于 2019-12-01 18:03:11

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.

Did you try doubling up you quotation marks as an escape character for quotes? i.e.

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

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. ")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!