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

Поиск
Список
Период
Сортировка
От Steve Atkins
Тема Re: Function to return number of words in a string?
Дата
Msg-id 20050509170530.GA12037@gp.word-to-the-wise.com
обсуждение исходный текст
Ответ на Re: Function to return number of words in a string?  ("Jim C. Nasby" <decibel@decibel.org>)
Список pgsql-general
On Mon, May 09, 2005 at 11:49:41AM -0500, Jim C. Nasby wrote:
> You can use a combination of regex
> (http://www.postgresql.org/docs/8.0/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP)
> and strpos inside a plpgsql function to do this, but using plpython or
> plperl might be faster. A C function would possibly be faster still.
>
> On Mon, May 09, 2005 at 11:21:28AM -0500, Peter Fein wrote:
> > 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())

    abacus=> select array_upper(string_to_array('one two three four', ' '), 1);
     array_upper
    -------------
               4
    (1 row)

Not that this is a _good_ way of doing it, but it is possible without resorting
to a PL.

Cheers,
  Steve


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

Предыдущее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL
Следующее
От: "Jonathan Lam"
Дата:
Сообщение: PostGreSQL -> SQL server