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!

Splitting strings to row when Newline character occur using regular expression

UtsavNov 22 2018 — edited Nov 29 2018

I have a table whose one of the cell contains multiple values separated by Newline character [chr(10)]

Now I want to convert the value within the column to the row level using regular expression substring

Current Data

S_no
Products
1

2,500 MG Doxytel+Amoxycylin+LOZ

2,250 MG Doxytell+Amoxycylin+LOZ

4,100 MG Doxytel Capl+Amoxycylin+LOZ

Expected Data

S_no
Products
1

2,500 MG Doxytel+Amoxycylin+LOZ

1

2,250 MG Doxytell+Amoxycylin+LOZ

14,100 MG Doxytel Capl+Amoxycylin+LOZ

I tried using select REGEXP_SUBSTR(PRODUCTS,'[^\A]+',1,level] from dual

connect by REGEXP_SUBSTR(PRODUCTS,'[^\A]+',1,level]  is not null;

But it is somehow skipping going beyond "+" and returning only "2,500 MG Doxytel"  and skipping "+Amoxycylin+LOZ"

Could you guys please help me out in solving this with regexp_substr ?

This post has been answered by mNem on Nov 22 2018
Jump to Answer
Comments
Post Details
Added on Nov 22 2018
4 comments
8,431 views