I'd like to change
{foo, {bar}, foobar}
to
{foo, bar, foobar}
in all rows that match '{.*{'. I.e. remove all curly braces { and } except the outer most pair.
So doing
mysql -h $H -u $U -p$P $DB -B -e "SELECT id FROM t WHERE col REGEXP '{.*{'" > bad.txt
selects all the rows that will need this substitution. How do I make this substitution very quickly?
EDIT:
Could I do it by
update table set column = REPLACE(column,'{','');
Then restore the out most pair
update table set column = REPLACE(column,'^','{');
update table set column = REPLACE(column,'$','}');