您好,登錄后才能下訂單哦!
遇到一個powershell Here string 中的換行導(dǎo)致的坑,這里來驗證下不同版本中powershell here string 的行為。如果你不有心注意,很可能踩坑。
同PS2,驗證方法同PS2
同PS2,驗證方法同PS2
$a=@"
`r`n
aa
"
但是你會發(fā)現(xiàn),powershell 在多個版本中會給你再多加一個\n
PS C:\> $a=@"
>> `r`n
>> aa
>> "@
>>
PS C:\> $a.length
5
PS C:\> $a=@"
>> `r`n
>> aa
>> "@
>>
PS C:\> $a.legnth
PS C:\> $a.length
5
PS C:\> $b=$a -replace '(\r\n|\r|\n)',"`r`n"
PS C:\> $b.length
6
PS C:\> $b
aa
PS C:\>
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。