PowerShell -match operator and multiple groups

前端 未结 5 1593
南笙
南笙 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 01:58

    You can do this with the Select-String cmdlet in V2 but you need to specify the -AllMatches switch e.g.:

    $formattedMessage | Select-String 'regexpattern' -AllMatches
    

    Keep in mind that with the -match operator the primary thing you are doing is looking for "a" match i.e. is the regex pattern matched or not.

提交回复
热议问题