Re: regexp_replace: LF, CR, or tab

From: Osvaldo Kussama <osvaldo(dot)kussama(at)gmail(dot)com>
To: seiliki(at)so-net(dot)net(dot)tw
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: regexp_replace: LF, CR, or tab
Date: 2010-02-27 13:47:33
Message-ID: 690707f61002270547q4fd789ev7f1b5d6617c4d120@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2010/2/27 <seiliki(at)so-net(dot)net(dot)tw>:
> Hi!
>
> I am trying to replace characters '\r', '\n', or '\t' with space character ' '. As an example, I want string "A\t\n\rB" becomes "AB".  The following statement seems to be not working. What mistake have I made?
>
> TIA
>
> CN
> ========
>
> select regexp_replace(E'A\r\n\tB',E'[\r\n\t]',' ');
>  regexp_replace
> ----------------
>  A
>         B
> (1 row)
>

Try:
select regexp_replace(E'A\r\n\tB',E'[\r\n\t]',' ','g');

Osvaldo

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-02-27 16:26:44 Re: Can not match 0 on bytea
Previous Message Daniel Verite 2010-02-27 09:34:42 Re: Can not match 0 on bytea