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
573 views
in Technique[技术] by (71.8m points)

escaping - Can I use a single quote in a PowerShell 'string'?

I want to include an apostrophe in my string. Is it possible to do without using double quotes?

'This is a quote. Can`'t I just include a single quote in it?'
'This is another quote that doesn't work'
See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)
'Escape a single quote '' using a double single quote'

See the help for the quoting rules.

You can check out the help in the powershell command line by typing:

Get-Help about_Quoting_Rules

It explains that backticks are interpreted literally in single-quoted strings.

Because the contents of single-quoted strings are interpreted literally, you cannot use the backtick character to force a literal character interpretation in a single-quoted string.


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

...