Given the sentence below, how do I match all numbers?
Run Time: 72 hours, 14 minutes, and 20 seconds
The words hours
, minutes
and seconds
could also be singular.
The closest match so far:
/Run Time: (\d ) hour. (\d ) minute. (\d ) second/
That matches the 72, but only the 4 and 0 of 14 and 20.
I'm using this tool to test: https://regex101.com/
I've tried so many different combinations but I simply don't understand what's going on.
CodePudding user response:
Exclude the number and capture them
[^0-9] (\d )[^0-9] (\d )[^0-9] (\d )