Re: regexp_replace usage

From: chester c young <chestercyoung(at)yahoo(dot)com>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: sql pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: regexp_replace usage
Date: 2006-10-02 15:15:03
Message-ID: 20061002151503.88141.qmail@web54309.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thanks !

Michael Fuhr <mike(at)fuhr(dot)org> wrote:Offhand I can't think of a way to do what you want with regexp_replace()
but you could use PL/Perl. Something like this should work:

CREATE FUNCTION mcfix(text) RETURNS text AS $$
$_[0] =~ s/\bMc([a-z])/Mc\u$1/g;
return $_[0];
$$ LANGUAGE plperl IMMUTABLE STRICT;

SELECT mcfix('John Mcneil');
mcfix
-------------
John McNeil
(1 row)


---------------------------------
How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ezequias Rodrigues da Rocha 2006-10-02 15:41:52 Doubt with Joins
Previous Message Michael Fuhr 2006-10-02 03:56:09 Re: regexp_replace usage