regex - I need regular expression to replace everything than certain text -
I want to write a regular expression which can extract time data in the form in the following examples:
2 hours 2 hours 2 hours 30 minutes 2.5 hoursI am trying to get it written and written in regular expressions -
[^ 0-9 \ s ( H | h) in our (m | m)].
But when I test it - this letter matches 'our' and 'in' separately. I want to match only the words 'bell' and 'bell' and their Do not want subsets of characters
Maybe try to do something like that?
(\ d + (?: \. \ D +)?) \ S (?: H | h) ours? (?: \ S (\ d +) \ s (?: M | m) inutes?)?
The first group will be the number of hours, the second group is the number of minutes
Comments
Post a Comment