Solved

REGEXP_SUBSTR extraction from string

Posted on 2010-11-08
8
1,216 Views
Last Modified: 2012-05-10
Dear experts and regular expression wizards,

I need to extract numbers with European comma seperation from a string.
For instance 4,32.

Sometimes, however,  I will have a single integer such as 4 embedded in a string only.
I tried the regular expression below, which only works for  comma separarated values. Can you please show me how to extract single numbers as well as.

To be precise I need a regular expression that extracts 4 and 4,32 from a string such as  "The result values are 4 and 4,32! Recommended task..."
select to_number(trim(regexp_substr(str_result,'[0-9][,][0-9]'))) str_result, decode((str_bewertung),'A+',9,'A',8,'A-',7,'B+',6,'B',5,'B-',4,'C+',3,'C',2,'C-',1) as bewertungspunkte, str_bewertung str_bewertung from (select str_typ, str_result, str_bewertung from tbl_matrix_result where LNG_GEBIET = :xp_cnt_gebiet and STR_LRT = :xp_str_lrt and INT_BE = :xp_be and INT_WG = :xp_wg and EVAL_TYPE = 4 and lower(str_typ) = 'biotopbaum' );

Open in new window

0
Comment
Question by:skahlert2010
8 Comments
 
LVL 17

Expert Comment

by:Shinesh Premrajan
ID: 34083552
select to_number(trim(regexp_substr(str_result,'[0-9,]'))) str_result

Hope this helps
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 34083570
if the string has more than one number in it,  what are you expecting the results to be?  One row per value?  or one column per value?  The first is possible,  the second is not.
Is there a maximum number of numbers you might expect? Will it be only 1 or 2 or could there be many?
0
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 500 total points
ID: 34083736
You can try this: (\d[^,])+|(\d+,\d+)+

Cheers
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:skahlert2010
ID: 34083771
Thanks marqusG!

Brilliant! I's working great! Do you guys have a reference for regular expressions?
I am sometimes having trouble to build my own function successfully since I am exactly not fond of the parameters.

Bye!
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 34083794
Glad to helped you. You find a good reference here http://regexplib.com and here: http://www.regular-expressions.info/

Cheers
0
 

Author Comment

by:skahlert2010
ID: 34084185
Thanks! That will be quite handy in the future!

Brgds....
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 34085305
For some bug, link to accept answer and awrad points is missing. Please, skahlert2010, click Request attention link to ask a moderator to award points to my answer and close question.

Thanks and good bye

Marco
0
 

Author Closing Comment

by:skahlert2010
ID: 34086427
Thanks for the excellent answer!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to free up undo space? 3 50
REGEX HELP 11 49
Read XML values 8 42
oracle forms question 22 42
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to recover a database from a user managed backup

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question