I have the lines of the following format
9/14/2021 6:01:14 PM 42 (3224) Receive rate: 39338 B/s
9/14/2021 6:01:29 PM 92 (940) Receive rate: 215363 B/s
I need to extract 2 pieces of data from here: timestamp and the actual rate, e.g.
9/14/2021 6:01:14 PM, 39338
9/14/2021 6:01:29 PM, 215363
I am using grouping and came up with the following pattern:
^(.*)\s*[0-9]*\s+\([0-9]+\)\s+Receive\s+rate:\s+([0-9]+)
With such a pattern, I successfully return my second group (39338, 215363), but for the first group it goes too far beyond the AM/PM point and the first group becomes 9/14/2021 6:01:14 PM 42
.
If I change the pattern to
^(.*) [0-9]*\s+\([0-9]+\)\s+Receive\s+rate:\s+([0-9]+) -> 3 spaces instead of the first \s*
it matches as expected, but there is no guarantee there will be 3 spaces, so I need to use whitespace char with zero or more.