Extracting Specific String

Hello Expert,

I need a code snippet that will help in extracting specific text from a string in oracle.  I have attached my sample data here.  I need to extract, and in that order

diamond CU/ BatchID/com.diamond.banking.0000 BatchPlatformGroup
diamond CU/ BatchID/com.diamond.banking.0000 BatchPlatformGroup
diamond Credit Union/ BatchID/com.diamond.banking00000 BatchPlatformGroup

Open in new window

Thanks in advance for your help!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
Assuming that is three rows of data try this:
select regexp_substr(mycol,'[0-9.]+') from mytable;
slightwv (䄆 Netminder) Commented:
If that is one row in a table, try this:

select regexp_substr(mycol,'/([0-9.]+)',1,level,null,1) from mytable
connect by level <= regexp_count(mycol,'/[^/]+/');
If the pattern you are looking for is a series of 4 digits separated by a period

then try this

select regexp_substr(yourstring,'([0-9]\.){3}[0-9]',1,level) from yourtable
connect by regexp_substr(yourstring,'([0-9]\.){3}[0-9]',1,level)  is not null

Open in new window

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

fb1990Author Commented:
thanks slightwv and sdstuber.  

The pattern that i am looking for is first 4 digit after the first back slash.  from this example diamond CU/ example, i need to get
slightwv (䄆 Netminder) Commented:
Any of the posted code should do that.

To be 100% sure:  We still need to know if your sample data is 3 rows in the table or 1?
fb1990Author Commented:
sorry... i did not answer that question.

my data is 3 rows.

slightwv (䄆 Netminder) Commented:
Then try my fist post instead of the second.  My first post will fail if the credit union name can have a number in it.

Like this:
diamond 1 CU/ BatchID/com.diamond.banking.0000 BatchPlatformGroup

If that is a possibility, use sdstuber's.  Just remove the recursion.

select regexp_substr(yourstring,'([0-9]\.){3}[0-9]') from yourtable

Now that will fail if you can have data like:
diamond CU/ BatchID/com.diamond.banking.0000 BatchPlatformGroup

If that is a possibility and you really need it after the slash, let us know.
fb1990Author Commented:
i cannot have data like this diamond CU/ BatchID/com.diamond.banking.0000 BatchPlatformGroup

But, i can have data like
diamond 1 CU/ BatchID/com.diamond.banking.0000 BatchPlatformGroup

diamond 1 Credit Union/ BatchID/com.diamond.banking.0000 BatchPlatformGroup
slightwv (䄆 Netminder) Commented:
OK then, go with my altered version of what sdstuber posted.

SELECT REGEXP_SUBSTR(yourstring, '([0-9]\.){3}[0-9]')  from yourtable

will work

what that search does is:

find the first set of 3 digits followed by a period  (for example:   1.2.3.)
that is then followed by another digit   (

so,  would be found
1 would be skipped
1234 would be skipped
1.2.3  would be skipped
1.2.3.  would be skipped
1..2.3.  would be skipped
1.2.3.x  would be skipped  would be skipped

is that what you want?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fb1990Author Commented:
Thank you slightwv nd sdstuber.  The solution provided by sdstuber worked like a charm
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.