Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8786597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:40:35+00:00 2026-06-13T21:40:35+00:00

I’m trying to extract the # of minutes from a text field using Oracle’s

  • 0

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+), a conditional statement, doesnt’ match anything.

What is wrong with my conditional statement?

** EDIT **

WITH DATA AS (

  SELECT 'Treatment of PC7, PT1 on left. 15 min.' COMMENTS FROM DUAL

  UNION ALL

  SELECT '15 minutes.' COMMENTS FROM DUAL

  UNION ALL

  SELECT '15 minutes' COMMENTS FROM DUAL

  UNION ALL

  SELECT '15 mins.' COMMENTS FROM DUAL

  UNION ALL

  SELECT '15 mins' COMMENTS FROM DUAL

  UNION ALL

  SELECT '15 min.' COMMENTS FROM DUAL

  UNION ALL

  SELECT '15 min' COMMENTS FROM DUAL

  UNION ALL

  SELECT '15min' COMMENTS FROM DUAL

  UNION ALL

  SELECT '15' COMMENTS FROM DUAL

)

SELECT  COMMENTS,
        REGEXP_SUBSTR(COMMENTS, '(\d+)\s?(?:min.*)?$', 1, 1) A,
        REGEXP_SUBSTR(COMMENTS, '\d+?(?= ?min)|^\d+$', 1, 1) B,
        REGEXP_SUBSTR(COMMENTS, '\d+?(?: ?min)|^\d+$', 1, 1) C

FROM DATA

Results (there must be a better way to format columns than as ‘code sample’):

COMMENTS A B C
Treatment of PC7, PT1 on left. 15 min.          
15 minutes.         
15 minutes          
15 mins.            
15 mins         
15 min.         
15 min          
15min           
15  15  15  15
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:40:37+00:00Added an answer on June 13, 2026 at 9:40 pm

    This Regex will work for you.

    ^.*?(\d+)(( ?min.*$)|$)
    

    Explanation

    • ^.*? – matches the beginning of the string, followed by any character 0 or more times
    • (\d+) – matches at least one digit and stores it in backreference position 1
    • ( ?min.*$) – matches a space (maybe), min, any character (maybe), then the end of the string.
    • (...|$) – if it can’t find min, it will see if there is the end of the string instead.

    Then instead of using REGEXP_SUBSTR(), use REGEXP_REPLACE() like this, replacing the entire string with what was stored in backreference position 1 (your number):

    REGEXP_REPLACE(COMMENTS, '^.*?(\d+)(( ?min.*$)|$)', '\1') A
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.