pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Emi Lu <emilu@encs.concordia.ca>
To: ktm@rice.edu <ktm@rice.edu>
Cc: Wes James <comptekki@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Simple method to format a string
Date: Wed, 20 Jun 2012 15:45:12 -0400
Message-ID: <4FE22848.5050309@encs.concordia.ca> (raw)
In-Reply-To: <20120620182142.GF6547@aart.rice.edu>
References: <4FE1E14A.8060603@encs.concordia.ca>
	<CAFjCMHuPLR1aEHr8agWm1ihT+8XNRZcFeKkPY1oQ_GABPOMfGg@mail.gmail.com>
	<20120620182142.GF6547@aart.rice.edu>


> Just a small optimization would be to use a backreference with regexp_replace
> instead of regexp_matches:
>
> select regexp_replace('foobarbaz', '(...)', E'\\1 ', 'g');
>   regexp_replace
> ----------------
>   foo bar baz

Great.

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;





view thread (4+ messages)

Message-ID: <4FE22848.5050309@encs.concordia.ca>
Permalink:  ../4FE22848.5050309@encs.concordia.ca/
Also on:    postgresql.org/message-id/4FE22848.5050309@encs.concordia.ca

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: emilu@encs.concordia.ca, ktm@rice.edu, comptekki@gmail.com
  Subject: Re: Simple method to format a string
  In-Reply-To: <4FE22848.5050309@encs.concordia.ca>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox