Единственный способ сделать это - использовать рекурсивный CTE:
with cte as (
select NULL as chr, value as rest, 0 as in_braces, '' as output, value, 0 as lev
from t
union all
select substr(rest, 1, 1),
substr(rest, 2),
(case when rest like '[%' then 1
when rest like ']%' then 0
else in_braces
end) as in_braces,
(case when in_braces or rest like '[%' then output
else output || substr(rest, 1, 1)
end),
value, lev + 1
from cte
where rest <> ''
)
select cte.value, cte.output
from cte join
(select value, max(lev) as max_lev
from cte
group by value
) m
on cte.value = m.value and cte.lev = m.max_lev;
Здесь - это скрипта db <>.