How to use "regular expression" to separate specific strings in Oracle
2
votes
2
answers
2809
views
I have a string
'(1:30,2:4,52:0,8:1)'
, and I need to use a regular expression to have this output:
field1 field2 level
1 30 1
2 4 2
52 0 3
8 1 4
The query I've wrote so far is:
select distinct trim(regexp_substr('1:30,2:4,52:0,8:1','[^:,]+',1,level)) repfield,level lvl
from dual
connect by regexp_substr('1:30,2:4,52:0,8:1', '[^:,]+', 1, level) is not null
order by lvl
Asked by Pantea
(1510 rep)
Jul 14, 2019, 05:32 AM
Last activity: Jul 14, 2019, 08:47 PM
Last activity: Jul 14, 2019, 08:47 PM