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.

Extracting substring using regexpr_substr

ricvar_2001Aug 29 2016 — edited Aug 30 2016

Hi

I need to extract the nth occurrence of a pattern in a string and I thing regexpr_substr can help me. The pattern is any string between a separator character (for example a semicolon )

Examples:

StringIf I use...I get
a;b;cregexp_substr('a;b;c','[^*;]+',1,3) to get the 3rd occurrencec, and it's ok
a;b;c;;d (there are two colons between c and d)regexp_substr('a;b;c;;d','[^*;]+',1,4) to get the 4th occurrenced, and I expected a null

Is there a way to obtain what I expect using regexp_substr? I used to do this with instr and substr but I wonder if there is a better way.

This post has been answered by Solomon Yakobson on Aug 29 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 27 2016
Added on Aug 29 2016
6 comments
2,955 views