Search Postgresql Archives

Re: Simple method to format a string?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




    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;

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux