PowerShell: Here-String
What is Here-String
Here-string is a syntax for quoting long multi-lines text.
Here-String with APOSTROPHE delimiter (Literal)
Syntax
$x = @'
text_body
'@
- text_body is the string.
- text_body can be multiple lines.
- text_body is taken literally. No special interpretation.
- The last line of text_body does not include the newline character.
@'
must be on its own line.'@
must be on its own line.
Example
$x = @' some '@ $x -eq 'some' # True
Here-String with QUOTATION MARK delimiter (Interpreted)
Syntax
$x = @"
text_body
"@
Similar to Here-String with APOSTROPHE delimiter, except that dollar sign $ sequence are considerd as expressions and GRAVE ACCENT ` is escape sequence.
Example
$x = 3 $text = @" aa`nbb $x cats "@ $text <# aa bb 3 cats #>
PowerShell, string and regular expression
- PowerShell: String
- PowerShell: Single Quoted String
- PowerShell: Double Quoted String
- PowerShell: Here-String
- PowerShell: Escape Characters
- PowerShell: String Length
- PowerShell: Join String
- PowerShell: Split String
- PowerShell: Format String
- PowerShell: String Methods
- PowerShell: String Wildcards
- PowerShell: Regular Expression Operators
- PowerShell: Regex Result ($Matches)
- PowerShell: Regular Expression Syntax