我可以在Powershell'string'中使用单引号吗? [英] Can I use a single quote in a Powershell 'string'?

查看:103
本文介绍了我可以在Powershell'string'中使用单引号吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的字符串中加入一个撇号。可以不使用双引号吗?

 '这是一个报价。不,我只是包括一个单引号?'
'这是另一个报价,它不工作'


解决方案

 '使用双重单引号'逃避单引号'

请参阅引用规则



您可以通过键入以下命令,查看powershell命令行中的帮助:

  Get-Help about_Quoting_Rules 

它解释说,反引号是单引号的字符串解释。


因为单引号字符串的内容是从字面上解释的,你不能使用反向字符强制在单引号字符串中的文字字符解释。



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'

解决方案

'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.

这篇关于我可以在Powershell'string'中使用单引号吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆