PowerShell -match operator and multiple groups

前端 未结 5 1583
南笙
南笙 2021-02-20 01:28

I have the following log entry that I am processing in PowerShell I\'m trying to extract all the activity names and durations using the -match operator but I am onl

5条回答
  •  无人及你
    2021-02-20 02:05

    I was able to get all of the groups by defining a Regex and then calling .Matches on that Regex. Still curious to know if this can be done with the -match operator in PowerShell.

    $detailRegex = [regex]"(Get\sClient\sModel|Parse\sExpression|Get\sAbstract\sQuery|Compile\sQuery|Execute\sQuery|Get\sQuery\sPlan\sComplexity|Async\sTotal|Total)\s-\sduration\(([0-9]*)"
    $detailRegex.Matches($formattedMessage)
    

提交回复
热议问题