> select trim(regexp_replace('123456', '...', '\& ', 'g'));
>
> If you don't care about trailing space remove the 'trim()'.
>
> The replacement string may need to be escaped differently depending
> on your PG version and setting for standard_conforming_strings. For
> example: E'\\& '
After combined with several more replace(s), regexp_replace will provide
me the expecting result.
Thanks!
Emi
--
select
regexp_replace(
replace(
replace(col-val, ' ', ''), '-', ''),
.... replace...
'(...)', E'\\1 ', 'g')
from tn;