如何在Powershell中转义大括号

我有这个

$content = "loose text{{comments}} = {{yolo}}{{comments}} = {{yolo2}}{{comment}} = {{yolo3}}{{comment}} = {{yolo4}}loose text2";

,我想逃脱括号。我在某处读到要逃脱它,请将它们加倍,但即使那样也无法正常工作。

我明白了

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
bierlaopo 回答:如何在Powershell中转义大括号

PS中的转义字符为“ back-tic” =`。但是,在显示的代码中,仅在字符串中包含{}就不会有任何问题。

无论哪种情况,只要使用以下示例,就可以对其进行转义:

$content = "loose text`{comments`} = `{yolo`}`{comments`} = `{yolo2`}`{comment`} = `{yolo3`}`{comment`} = `{yolo4`}loose text2"
本文链接:https://www.f2er.com/3157304.html

大家都在问