regex - sed to replace comma outside parentheses -
i have partial sql string.
select id,to_char(ts2date(created_t),'dd-mm-yyyy'),name,segment_code sometable using sed, tried replace comma reside outside outmost parentheses string char '~'.
the desired result be:-
select id~to_char(ts2date(created_t),'dd-mm-yyyy')~name~segment_code sometable here tried:-
sed ' :a s/[,]\(.*(\)/~\1/g s/\().*\)[,]/\1~/g ta but result become:-
select id~to_char(ts2date(created_t)~'dd-mm-yyyy')~name~segment_code sometable how can ignore comma inside outmost parentheses?
tq answer .. :)
it's not possible reach such goal pure sed regex. correct/incorrect bracketing , depth cannot recognized regular automatas (and therefore cannot recognized regular expressions).
if want reach "regex", might want use perl , look-ahead/look-behind features. or write simple loop checks bracketing.
Comments
Post a Comment