Search code examples
powershellcommand-linedouble-quotes

remove or ignore double quotes in a string - powershell


I think I have a simple problem but I can't seem to find the answer.

This is a part of the string I am working with

$text = "INDEPENDENT ELECTORAL AND BOUNDARIES COMMISSION
POLLING STATION: "ABC DEF GHIJKL (001)" 
STREAM:123"

When I try to work with this, I get an error because of the double quotes in $text. I know I can escape the double quotes using a back tick, but the entire string is too big for me to go through it all.

I wonder if there is a simple way to ignore or remove all double (and single, too) quotes except for the first and last.


Solution

  • You can solve this by using here-strings:

    $Text = @'
    All the symbols I/ can ` hope for
    between " the *>$ opening $() and closing ${}
    of the symbols
    '@