I am parsing a CSV file that contains text that represents duration, which might be any combination of hours, minutes, or both. For example:

1. "1 hour 30 minutes"
2. "2 hours"
3. "45 minutes"

I want to be able to do this: `duration = h.hours + m.minutes` and make sure that `h` is hour (if exists) and the same for `m`.

I tried solving this with this regex `/(\d*)\s?hour\D*(\d*)\s?min/)` , but this won't detect minutes alone, or hours alone.

So I changed it to this `/(\d+)\s?\D*\s?(\d*)/`, but it's wrong too because there is no way to tell if the value is an hour or minute, so I can convert it to `hour` or `minutes`.

I am confused on which way could solve this problem in my app. Is it regex, hash, matching, or any other way? Any help or advice is appreciated.