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 parse/extract list of values using Regular Expressions?

Dejan T.Mar 20 2019 — edited Mar 21 2019

Dear Oracle Experts,

I got some task to solve it, but unfortunately, I am not able to solve it using pure SQL. Therefore, I would it really appreciate, if someone could help me.

Here are the test data:

with data as (

select '1="Value 1",2="Value 2",3="Value 3"' as str from dual

union all

select 'A="Field A",B="Field B",C="Field C"' from dual

union all

select 'Def1="Definition 1",  Val1="Value 1"' from dual

union all

select 'Obj-1="Object Name 1", Def-1="Object Definition 1"' from dual)

select str

       -- RegExp comes here--

from data;

I want to get rid of: any characters before equal sign, equal sign itself, white space outside of "" and at the end all " characters.

The result I would like to get is:

STR
Value 1,Value 2,Value 3
Field A,Field B,Field C
Definition 1,Value 1
Object Name 1,Object Definition 1

Is it possible at all using pure SQL or not?

Thanks in advance & best regards

Dejan

This post has been answered by mathguy on Mar 20 2019
Jump to Answer
Comments
Post Details
Added on Mar 20 2019
5 comments
950 views