On 05/09/05 11:21 AM CDT, Peter Fein <pfein(at)pobox(dot)com> said:
> Hiya-
>
> I'm looking for a function to return the number of words in a string,
> split on whitespace. I'm coming from python, so I may just write it
> in that but I wanted to check first. In python, one would write:
>
> s="some string or other"
> len(s.split())
For the archives:
CREATE OR REPLACE FUNCTION word_length(text)
RETURNS int4 AS
'return len(args[0].split())'
LANGUAGE 'plpythonu' IMMUTABLE STRICT;
Thanks all.
--
Peter Fein pfein(at)pobox(dot)com 773-575-0694
Basically, if you're not a utopianist, you're a schmuck. -J. Feldman