Re: trimming functions.

From: Hubert Lubaczewski <hubert(dot)lubaczewski(at)eo(dot)pl>
To: javier garcia - CEBAS <rn001(at)cebas(dot)csic(dot)es>, pgsql-general(at)postgresql(dot)org
Subject: Re: trimming functions.
Date: 2003-06-23 11:47:46
Message-ID: 20030623134746.1c3b38e0.hubert.lubaczewski@eo.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 23 Jun 2003 12:41:19 +0200
javier garcia - CEBAS <rn001(at)cebas(dot)csic(dot)es> wrote:

> So I still need to improve the SELECT to remove all possible symbols after
> the first group of alphabet characters to get a 'code_trimmed' column with
> just the characters:(NJ, AG, OL, LI, I, NJ, PH, AG, PD, L, M, MD, L).
> Possible 'non alphabet' symbols are '{+/^('
> Any idea?

simple pl/perl function should do the trick.

maybe something like this:
create function d_trim(text) returns text as '
my $sString = shift;
$sString =~ s/^\\(*([A-Z]+).*$/$1/;
return $sString;
' language 'plperl';

i'm not entirelly sure if this function will work - i wrote it without anytesting, but it is so simple, one shouldn't have any problems correcting/modifying it's behaviour.

depesz

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2003-06-23 12:21:44 Re: [GENERAL] interesting PHP/MySQL thread
Previous Message The Hermit Hacker 2003-06-23 11:33:05 Re: [GENERAL] interesting PHP/MySQL thread