Re: Function to return number of words in a string?

Поиск
Список
Период
Сортировка
От Peter Fein
Тема Re: Function to return number of words in a string?
Дата
Msg-id 20050509131542.6713399e@layout.pfein.org
обсуждение исходный текст
Ответ на Function to return number of words in a string?  (Peter Fein <pfein@pobox.com>)
Список pgsql-general
On 05/09/05 11:21 AM CDT, Peter Fein <pfein@pobox.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@pobox.com                 773-575-0694

Basically, if you're not a utopianist, you're a schmuck. -J. Feldman

В списке pgsql-general по дате отправления:

Предыдущее
От: Brendan Jurd
Дата:
Сообщение: Re: Shorthand for foreign key indices
Следующее
От: "Craig Bryden"
Дата:
Сообщение: Clustering Database Servers