我試圖從一個變量grep的一些數據字符串:轉換的ArrayList在PowerShell中
Select-String -inputObject $patternstring -Pattern $regex -AllMatches
| % { $_.Matches } | % { $_.Value } -OutVariable outputValue
Write-Host $outputValue
要在同一outvariable,我試圖做的字符串操作
$outputValue.Substring(1,$outputValue.Length-2);
失敗,說明outputValue是一個ArrayList
。
如何將Arraylist
轉換爲String
?
您是否曾嘗試先在$ outputValue上執行連接? Ala $($ outputValue -join「't」)這會給你串行化爲一個製表符分隔字符串的數組列表值。 –