PowerShell: Quote String
Ways to Quote String
String is a sequence of characters. There are 3 syntax to write string literals.
- 'singe quoted string'.
- Double Quoted String
- Here-String
Single Quoted, Literal String
- Character sequence between APOSTROPHE
'single quote'
is literal string. - Can contain multiple lines.
- Backslash is literal, GRAVE ACCENT
`
also literal.
$x = 'some thing' echo $x
Include a Single Quote
To include a single quote inside single quoted string, use two single quotes.
# double single quote becomes a single quote $x = 'don''t' $x -eq "don't"
# backslash is literal, GRAVE ACCENT also literal $x = 'a\n`nb'
Double Quoted String (Expandable String)
Here-String
PowerShell String
- PowerShell: Quote String
- PowerShell: Double Quoted String, String Expansion
- PowerShell: Here-String
- PowerShell: Escape Characters
- PowerShell: String Operators
- PowerShell: Join String
- PowerShell: Split String
- PowerShell: Format String
- PowerShell: String Methods
- PowerShell: String Wildcards
- PowerShell: Regular Expression Operators
- PowerShell: Regular Expression Syntax