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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Split a string using regexp_substr with consecutive delimiter

sblandin1973Jul 7 2014 — edited Jul 8 2014

I have to split a string with pipes as delimiter. A string like this for example:

'THIS|IS|AN|EXAMPLE'

If I do something like this:

SELECT REGEXP_SUBSTR('THIS|IS|AN|EXAMPLE', '[^|]+', 1, 4) FROM DUAL

I should obtain the word EXAMPLE

But if the string is like this:

'THIS|IS||AN|EXAMPLE'

With the above query I still get EXAMPLE, but the word should be in the next position (5) because after IS there should be an empty element

Is it possible to modify the regular expression to get also the empty element?

Thanks in advance

This post has been answered by Greg Spall on Jul 7 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 5 2014
Added on Jul 7 2014
16 comments
23,619 views