I have a table with a clob column that I need to extract data from. The column looks like this:
| Column1 |
|---|
| Name=John Smith. Branch Number=12345. Type of Event=Seminar. Date=06/22/2021. etc.. |
I would like to extract only the data between each of the equals signs (=) and the immediately following periods (.), so that the final output looks like this:
| Name | Branch_Number | Type_of_Event | Date |
|---|---|---|---|
| John Smith | 12345 | Seminar | 06/22/2021 |
I've tried this:
Select
regexp_substr(Column1,'\Name=([^.]+)',1,1,null,1) as Name
, regexp_substr(Column1,'\Branch Number=([^.]+)',1,1,null,1) as Branch_Number
, regexp_substr(Column1,'\Type of Event=([^.]+)',1,1,null,1) as Type_of_Event
, regexp_substr(Column1,'\Date=([^.]+)',1,1,null,1) as Date_of_Event
From table1
Where...
I know there are at least mistakes in the '1,1,null,1' parts (I could only locate these online), because the only column that ends up working is the first one, the other 3 show blanks.
Is there a way to extract each data field between each equals sign and each immediately following period into separate columns?
Any help would be great, thank you in advance. Apologies if my code makes anyone cringe, I just started using Oracle SQL Developer recently and first time using REGEX.
Working but messy solution:
Select
SUBSTR(Column1, INSTR(Column1, 'Name=', 1, 1) + length('Name='), INSTR(Column1, '.', INSTR(Column1, 'Name=', 1, 1), 1) - INSTR(Column1, 'Name=', 1, 1) + length('Name='))) as Name
, SUBSTR(Column1, INSTR(Column1, 'Branch Number=', 1, 1) + length('Branch Number='), INSTR(Column1, '.', INSTR(Column1, 'Branch Number=', 1, 1), 1) - INSTR(Column1, 'Branch Number=', 1, 1) + length('Branch Number='))) as Branch_Number
, SUBSTR(Column1, INSTR(Column1, 'Type of Event=', 1, 1) + length('Type of Event='), INSTR(Column1, '.', INSTR(Column1, 'Type of Event=', 1, 1), 1) - INSTR(Column1, 'Type of Event=', 1, 1) + length('Type of Event='))) as Type_of_Event
, etc...
From table1
Where ...