Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get substring between the 1st and 2nd occurrence of a character in oracle11g?

bdfcd6d0-7f05-4816-9bde-530210cf6eceMay 15 2018 — edited May 16 2018

I have texts like below in a column-

a|bbb|cc|dddd 
d||ff|gg
a|zzzz|pp|rrr

I want to display the text between 1st "|" and 2nd "|" symbols. Below given should be the output.

Output 
------
bbb null zzzz

Tried with below query, but it gives me 'ff' instead of null.

SELECT regexp_substr('d||ff|gg','[^|]+',1,2) regexp_substr FROM dual; 

How should I go about doing this?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 13 2018
Added on May 15 2018
8 comments
17,825 views