sql query to get value from a string

hi fellow experts,
- i am working on a data conversion task and after 24hours of non-sleep, i'm unable to get my brain working on this. i have list of data as below in an Oracle table, and i need to extract the value in middle, in-between the two underscore '_'. the length can be vary:  

column1
======================
asbc134_123acd_2345-10
a655s_bgddg_as45-05
s5gg6a_bhb89hj_2f677-15
dds4rr4_19898sd_265ff-01


- expected result:
column1
======================
123acd
bgddg
bhb89hj
19898sd

- any method is welcome either using regular expression or substr-instr...
LVL 23
OP_ZaharinAsked:
Who is Participating?

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

x
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.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
instr has the 4th parameter of nth occurance, which should make something like this:
http://www.techonthenet.com/oracle/functions/instr.php
substr( column1, instr( column1, '_' ) + 1, instr( column1, '_', 1, 2) - instr( column1, '_' ) - 1 )

Open in new window

0

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
santhimurthydCommented:
check with this
SUBSTR(columnname ,instr(columnname , '_')  , instr(columnname, '_', 1, 2))
0
CluskittCommented:
Quite a few ways to do this. One, probably not the most efficient:
LEFT(SUBSTR(column1,INSTR(column1,'_'),LEN(column1)),INSTR(SUBSTR(column1,INSTR(column1,'_'),'_')
0
OP_ZaharinAuthor Commented:
- angelll suggestion works perfect, thank you!. i've also try the other two however return error.

OP
0
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.