Quick & Dirty: How to parse a delimited string and get the nth element

March 2, 2015 at 9:55 pm | Posted in Oracle Developement | Leave a comment

I have a comma delimited string:

Now I want to extract the 3rd element (is) from it inside a select statement:

select regexp_substr('Hello,this,is,my,string'
                     , '[^,]+', 1, 3) 
  from dual;

To count the elements in my string I can use:

select regexp_count('Hello,this,is,my,string'
                    , ',', 1, 'i')+1 regexp_count 
   from dual;

Leave a Comment »

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Entries and comments feeds.

%d bloggers like this: