PowerShell -match operator and multiple groups

前端 未结 5 1649
南笙
南笙 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:48

    http://www.johndcook.com/regex.html gives a decent example

    And, by all means, simplify your expression:

    ^([^-]+)\s*-\s*duration\(([0-9]+)
    
    • start at the beginning of the line
    • capture all characters leading up to the first -
    • make sure there's a -
    • skip whitespace
    • make sure the word "duration(" exists
    • capture all digits after "duration("

提交回复
热议问题