From: | Bruce Guenter <bruceg(at)em(dot)ca> |
---|---|
To: | Ian Turner <vectro(at)pipeline(dot)com> |
Cc: | pgsql-general(at)hub(dot)org |
Subject: | Re: Stripping a prefix |
Date: | 2000-08-26 20:36:24 |
Message-ID: | 20000826143624.C27393@em.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Aug 25, 2000 at 09:28:59PM -0700, Ian Turner wrote:
> If the string is like `^www\.', then trim `w' and `.'.
But this trims all 'w's and all '.'s, even if the string doesn't start
with 'www.':
select trim(leading 'www.' from 'wfoo');
ltrim
-------
foo
(1 row)
I ended up writing a function to do it, and for the data sets I'm
dealing with, it's fast enough:
CREATE FUNCTION strip_www (text ) RETURNS text AS
'BEGIN
IF position(''www.'' IN $1) = 1 THEN
RETURN substring($1 FROM 5);
ELSE
RETURN $1;
END IF;
END;' LANGUAGE 'plpgsql';
--
Bruce Guenter <bruceg(at)em(dot)ca> http://em.ca/~bruceg/
From | Date | Subject | |
---|---|---|---|
Next Message | Dale Walker | 2000-08-27 00:52:32 | creating functions |
Previous Message | The Hermit Hacker | 2000-08-26 20:21:42 | Re: split up tables or one big one? |