Using regexp_replace to remove small words

From: "Henrique de Lima Trindade" <henrique(at)vivver(dot)com(dot)br>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Using regexp_replace to remove small words
Date: 2010-12-10 12:47:36
Message-ID: 001701cb9868$6e402770$4ac07650$@com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I'm trying to find a regular expression that removes all small (length < N)
words from a string. But, until now I've not been successful.

For example:

If I pass 'George W Bush' as parameter, I want regexp_replace to return
'George Bush'.

Other examples are:

select regexp_replace( 'Tommy Lee Jones', 'REGEX', ' ', 'g' ) => 'Tommy
Jones'

select regexp_replace( 'Dr Tommy Lee Jones', 'REGEX', ' ', 'g' ) => 'Tommy
Jones'

select regexp_replace( 'Tommy Lee Jones Jr', 'REGEX', ' ', 'g' ) => 'Tommy
Jones'

Thanks in advance,

HENRIQUE TRINDADE

ANALISTA DE SISTEMA II

( 55 (31) 3025-3550

+henrique(at)vivver(dot)com(dot)br

assinatura

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Reid Thompson 2010-12-10 13:21:23 Re: Tuning Postgres for single user manipulating large amounts of data
Previous Message Dmitriy Igrishin 2010-12-10 12:17:08 Re: A cronjob for copying a table from Oracle