I have following table in postgres 11.
col1
a;b;c
d/e/f
g and h
i with k
l + m
I would like to split this table based on certain delimiters (/,+,;,and,with]). The desired output is:
col1 col2
a;b;c a
a;b;c b
a;b;c c
d/e/f d
d/e/f e
d/e/f f
g and h g
g and h h
i with k i
i with k k
l + m l
l + m m
I am trying out below query.
select distinct * from table t,
UNNEST(REGEXP_SPLIT_TO_ARRAY(t.col1, '\s+[/|+|;|and|with]\s+')) s(col2)