Emi Lu wrote:
> Good morning,
> 
> Is there a simply method in psql to format a string?
> 
> For example, adding a space to every three consecutive letters:
> 
> abcdefgh -> *** *** ***

Depending on how you want 'extras' handled, you could work from
something like this:

   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'\\& '

HTH

Bosco.

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to