There are lines like:

Time 555.55 Time .55 Time 55 

With the help of regexp_substr I want to get the substrings in the form

 555.55 .55 55 

I try this expression [[:digit:]]*[\.][[:digit:]]* However, the last option does not cling (number without a dot) If I try [[:digit:]]*[\.]?[[:digit:]]* I don’t get anything at all. What am I doing wrong? Request example:

 with n as ( select 'Time 555.55' s from dual union all select 'Time .55' from dual union all select 'Time 55' from dual ) select s, regexp_substr(s, '[[:digit:]]*[\.]?[[:digit:]]*'), regexp_substr(s, '[[:digit:]]*[\.][[:digit:]]*') from n; 

    1 answer 1

    In this case, you should use the quantifier + instead of * , indicating the mandatory presence of at least one digit.

     '[[:digit:]]*\.?[[:digit:]]+' 
    • Works. But I do not understand why * does not fit. Explain, please, what's the catch? - Viktorov
    • one
      @lDrakonl See when you specify only * or ? (for example, in the expression '[[:digit:]]*' ) the regexp engine checks the first character of the string and if it does not match the pattern [[:digit:]] , considers that a match is found and the search ends there, but this match is empty (does not contain substrings). - Romario
    • Understood thanks! - Viktorov