I’m not sure if I’m even asking this question the right way or using the right notation, but here’s what I want to do.
I’ve done
$matches=$_|Select-String '(?smi)(\d*)\: (.*?)' -AllMatches | Foreach{$_.Matches}
Select-String returns type [MatchInfo], and the Foreach sucks out the Matches property of that type which is type [System.Array]
The $matches is an array of [System.Text.RegularExpressions.Group] elements for each match found, but what I want is a 2-D array of capture group value results.
That is, I want an array that contains elements like this:
$whatiwant=
($matches[0].Groups[1].Value,$matches[0].Groups[2].Value),
($matches[1].Groups[1].Value,$matches[1].Groups[2].Value),
($matches[2].Groups[1].Value,$matches[2].Groups[2].Value),
($matches[3].Groups[1].Value,$matches[3].Groups[2].Value),
...
How can I build this array?
Thanks.
I use this:
http://gallery.technet.microsoft.com/scriptcenter/New-PSObjectFromMatches-87d8ce87
It takes a regular expression argument, and produces custom PS Objects from the match groups of the input.