Regex if-else expression

Posted by craig on Stack Overflow See other posts from Stack Overflow or by craig
Published on 2012-11-06T16:58:51Z Indexed on 2012/11/06 16:59 UTC
Read the original article Hit count: 140

Filed under:
|
|

I'm trying to extract the # of minutes from a text field using Oracle's REGEXP_SUBSTR() function.

Data:

Treatment of PC7, PT1 on left. 15 min.
15 minutes.
15 minutes
15 mins.
15 mins
15 min.
15 min
15min
15

In each case, I'm hoping to extract the '15' part of the string.

Attempts:

  • \d+ gets all of the numeric values, including the '7' and '1', which is undesirable.
  • (\d)+(?=\ ?min) get the '15' from all rows except the last.
  • (?((\d)+(?=\ ?min))((\d)+(?=\ ?min))|\d+), an if-else statement, doesnt' match anything.

What is wrong with my if-else statement?

© Stack Overflow or respective owner

Related posts about regex

Related posts about Oracle