regex - SQL Regular expression to split a column (string) to multiple rows based on delimiter '/n' -
i have split column multiple rows. column stores string, , have split delimiter based on '/n'
have written below query. not able specify ^[/n]
. other 'n'
in string getting removed. please parse string
with sample ( select 101 id, 'name' test, '3243243242342342/n12131212312/n123131232/n' attribute_1, 'test value/nneenu not/nhoney' attribute_2 dual ) -- end of sample data select id, test, regexp_substr(attribute_1,'[^/n]+', 1, column_value), regexp_substr(attribute_2,'[^/]+', 1, column_value) sample, table( cast( multiset(select level dual connect level <= length(attribute_1) - length(replace(attribute_1, '/n')) + 1 ) sys.odcinumberlist ) ) regexp_substr(attribute_1,'[^/n]+', 1, column_value) not null /
you need use class [[:cntrl:]] , '[^/n]+' not syntactically either.
the escape char '\' , cannot use [] "wrap" special chars, need use () instead.(that grouping)
if want ignore cr (e.g.'\n') , use [^[:cntrl:]] in sec param in regexp_substr
more help: http://psoug.org/snippet/regular-expressions--regexp-cheat-sheet_856.htm
Comments
Post a Comment