regex - I need regular expression to replace everything than certain text -
i want write regular expression can extract time data in format in following examples:
2 hours 2 hours 2 hours 30 minutes 2.5 hour
i'm trying done , written following regular expression -
[^0-9\s(h|h)our(m|m)in\.]?
but when test - matches characters 'our' , 'in' separately. want match words 'hour' , 'hour' , not subset of characters.
perhaps try this?
(\d+(?:\.\d+)?)\s(?:h|h)ours?(?:\s(\d+)\s(?:m|m)inutes?)?
the first group number of hours, second group number of minutes
Comments
Post a Comment