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 hours  

I 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

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -