escaping single quote sign in PowerShell


I have a replace statement in my code whereby Band’s is being replaced by Cig’s. However when I put single quote it took the first sentence… Example ‘Band’

I tried to use double quote but it does not work. Do you know how to escape the single quote sign?


See Escape characters, Delimiters and Quotes and Get-Help about_Quoting_Rules from the built-in help (as pointed out by as Nacimota).

To include a ' inside a single-quoted string, simply double it up as ''. (Single-quote literals don’t support any of the other escape characters.)

Or, simply switch to double-quotes. (Double-quote literals are required when wishing to use interpolation or escape characters.)

(Don’t forget that -replace uses a regular expression)


escaping single quote sign in PowerShell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply