Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 9A1C09FB2D8 for ; Mon, 2 Oct 2006 12:15:20 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 81392-03 for ; Mon, 2 Oct 2006 15:15:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web54309.mail.yahoo.com (web54309.mail.yahoo.com [206.190.49.119]) by postgresql.org (Postfix) with SMTP id 8A1B29FB326 for ; Mon, 2 Oct 2006 12:15:07 -0300 (ADT) Received: (qmail 88143 invoked by uid 60001); 2 Oct 2006 15:15:04 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=FfXo+WTvOyWMLcxxB78lZE73W7+KRwQTmTOwZsvizCcEzDZPxoCLQXY/OJ40ibAdK7zjScxh9SlzhEoufYUF5cxUW0olUNX1IkE35RJsiJZmTSN071hu9xWt64T+hhDJyde5TUYoqMvZINFX3DTx2KYyAZ3v+gASOEjuUocVhO8= ; Message-ID: <20061002151503.88141.qmail@web54309.mail.yahoo.com> Received: from [216.184.28.50] by web54309.mail.yahoo.com via HTTP; Mon, 02 Oct 2006 08:15:03 PDT Date: Mon, 2 Oct 2006 08:15:03 -0700 (PDT) From: chester c young Subject: Re: regexp_replace usage To: Michael Fuhr Cc: sql pgsql In-Reply-To: <20061002035609.GA42444@winnie.fuhr.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1159626860-1159802103=:80275" Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.852 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS, HTML_40_50, HTML_MESSAGE X-Spam-Level: *** X-Archive-Number: 200610/2 X-Sequence-Number: 26391 --0-1159626860-1159802103=:80275 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Thanks ! Michael Fuhr 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. --0-1159626860-1159802103=:80275 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Thanks !

Michael Fuhr <mike@fuhr.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. --0-1159626860-1159802103=:80275--