我目前正在 PowerShell 上玩,我想知道如何在彼此之后呼叫多個函式,但給它們每個自己的行。
我目前有這個:
$leet= $text.replace("a", "4").replace("e", "1").replace("e", "3");
但我更想要這樣:
$leet= $text
.replace("a", "4")
.replace("e", "1")
.replace("e", "3");
但是 PowerShell 并不真正喜歡換行符,并且當我將 ` 添加到每行的末尾,然后再添加另一行時,它也不起作用。
那么,我是否遺漏了什么,或者這在 PowerShell 中是不可能的?
uj5u.com熱心網友回復:
正如Jeroen Mostert 所指出的,您可以通過指定運算子 ( .) 然后在它和右側運算元之間放置空格來免費獲得換行符:
$leet = $text.
Replace("a", "4").
Replace("e", "1").
Replace("e", "3")
(請注意,最后一次呼叫 ,Replace("e", "3")什么都不做 - 所有e's 都已被前面的呼叫替換)
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/345210.html
上一篇:ISE中的PowershellGet-Childitem
下一篇:Powershell例外問題
