Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
467 views
in Technique[技术] by (71.8m points)

grammar - What is an expandable string in PowerShell

In PowerShell's documentation, I have come across the expression expandable string:

Argument mode is designed for parsing arguments and parameters for commands in a shell environment. All input is treated as an expandable string unless it uses one of the following syntaxes:

Unfortunately, I am unable to find a definition for expandable string and my question is: what is an expandable string in PowerShell?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It is definitely unfortunate that, as of this writing, the official help topic on PowerShell string literals, about_Quoting_Rules doesn't introduce the term expandable string [update: the online version now does; to also see the update locally, you may have to run Update-Help].

An expandable string is:

  • A double-quoted string literal ("...")

    • By contrast, a single-quoted string ('...') is a verbatim (literal) string.
    • For an overview of all types of PowerShell string literals, which includes here-string variants (e.g., @"<newline>...<newline>"@), see the bottom section of this answer.
  • Double-quoted strings perform string interpolation (expansion).

    • This allows you to embed simple variable references as-is (e.g, "$var"), and expressions and whole statements via $() (e.g., "$($var.property)"). Escape verbatim $ (and ") chars. with `. Enclose variable names in {...} for disambiguation (e.g. "${var}").
    • For the complete rules, see this answer.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...