Summary: Learn two different techniques to replace strings inside another string by using Windows PowerShell.
I have the following string: this`”is a string. I want to remove the quotation mark (“) and replace it with nothing—no space, just nothing. I want the results to look like this: thisis a string. The backtick (`) is used to “escape” the quotation mark. How can I use the Replace method to replace the quotation mark with nothing, if the string is held in a variable $arr?
There are several approaches to this. Here are a couple of solutions:
- Use the Replace method from the system.string .NET framework class.
$arr.Replace(“`””,””)
- Use the ascii value of the quotation mark, and use the Replace method from the system.string .NET framework class.
$arr.Replace([char]34,””)
0 comments