So, I have no seen anything remotely helpful on google or SO about this.
I have an array of strings and I want to run -split
on each string in the array and end up with an array containing arrays of strings.
However when I do this:
$Strings | % { $_ -split ($Sep) }
PS flattens the result and I end up with an array of strings containing the concatenated result of every -split
.
E.g. For this
$Strings = @("a b c", "d e f")
$Sep = " "
$Strings | % { $_ -split ($Sep) }
I get @("a", "b", "c", "d", "e", "f")
but I want @( @("a", "b", "c"), @("d", "e", "f") )
. What exactly am I not doing right?
$Strings | % { ,@($_ -split $Sep) }