Select-String Regex

I am reading a file using get-childitem and passing it to select-string like so:

$regexTrans = ‘Transaction Type: [a-z]+’, 'Trade Amount: ', ‘CUSIP Number: \d+[a-z]\d+’, ‘Settlement Date: \d{2}[/]\d{2}[/]\d{2}’, ‘Fund Name [a-z]+[a-z]+[a-z]+’
$readfile = Get-ChildItem -Path C:\Test\FinancialStatements\FinStatement.txt
$Line = ($readfile | Select-String $regexTrans -AllMatches).Matches.Value

I am accessing the array like so:

$line[2] and it work fine but if I need just part of array like the date instead of ‘Settlement Date: \d{2}[/]\d{2}[/]\d’ how can I just get the \d{2}[/]\d{2}[/]\d’ part.

I am still learning and never played with regex or arrays

Thanks for helping me

I am still learning

What you’re talking about is called a capturing regex. You can define a portion of the regular expression as the bit you want to “keep,” or “capture.” These can be implemented using Named Groups in the expression. See RegEx Named Groups with Select-String for a basic example; the object returns by Select-String will have a Matches collection that includes whatever you captured.