Re: Simple method to format a string? - Mailing list pgsql-general

From Emi Lu
Subject Re: Simple method to format a string?
Date
Msg-id 4FE22FA3.2030502@encs.concordia.ca
Whole thread Raw
In response to Re: Simple method to format a string?  (Bosco Rama <postgres@boscorama.com>)
List pgsql-general
>     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;

pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: RETURNING MORE THAN ONE CUSTOM TYPE FROM FUNCTION
Next
From: Craig Ringer
Date:
Subject: Re: 32-bit libpq with 64-bit server