Re: proper regex_replace() syntax

From: Rick Genter <rick(dot)genter(at)gmail(dot)com>
To: Geoffrey Myers <lists(at)serioustechnology(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: proper regex_replace() syntax
Date: 2011-06-01 18:43:20
Message-ID: BANLkTi=JpyRDprQWcEj+Lmu=fR9_Car43Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jun 1, 2011 at 10:22 AM, Geoffrey Myers <lists(at)serioustechnology(dot)com
> wrote:

> I want to use regex_replace() to replace characters in multiple records.
>
> What I would like to do is this:
>
> select regex_replace((select fname from table), 'z', 'Z'));
>
>
> The problem is, the subquery returns more then one row.
>
> So, is there a way to do what I'm trying to do? That is, replace the same
> character in multiple records using regex_replace() ?
>

I think what you want is:

SELECT regex_replace(fname, 'z', 'Z') FROM table;

This should return a recordset where each row has one column which is the
result of regex_replace() on the corresponding row of table.
--
Rick Genter
rick(dot)genter(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Paolo Saudin 2011-06-01 19:15:43 SELECT to_timestamp crash PostgreSQL 9.1beta1
Previous Message Ken Tanzer 2011-06-01 18:40:56 Re: proper regex_replace() syntax