首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在powershell中转义大括号

如何在powershell中转义大括号
EN

Stack Overflow用户
提问于 2019-11-06 02:18:57
回答 1查看 272关注 0票数 0

我有这个

代码语言:javascript
复制
$content = "loose text{{comments}} = {{yolo}}{{comments}} = {{yolo2}}{{comment}} = {{yolo3}}{{comment}} = {{yolo4}}loose text2";

我想摆脱这些括号。我在某处读到,为了逃避它,你将它们加倍,但即使这样,它也不起作用。

我得到了

代码语言:javascript
复制
Cannot convert value "loose text{{comments}} = {{yolo}}{{comments}} = {{yolo2}}{{comment}} = {{yolo3}}{{comment}} = {{yolo4}}loose text2" to type "System.Xml.XmlDocument". Error: "The specified node cannot be inserted as the valid child of this node, 
because the specified node is the wrong type."
At line:1 char:1
+ $content = "loose text{{comments}} = {{yolo}}{{comments}} = {{yolo2}}{{comment}} ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RuntimeException
EN

回答 1

Stack Overflow用户

发布于 2019-11-06 06:18:19

PS中的转义字符是"back-tic“= `。但是,在所给出的代码中,字符串中只包含{}应该不会有任何问题。

在任何需要转义它的情况下,只需使用下面的示例:

代码语言:javascript
复制
$content = "loose text`{comments`} = `{yolo`}`{comments`} = `{yolo2`}`{comment`} = `{yolo3`}`{comment`} = `{yolo4`}loose text2"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58717254

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档