Using regexp_replace to remove small words - Mailing list pgsql-general

From Henrique de Lima Trindade
Subject Using regexp_replace to remove small words
Date
Msg-id 001701cb9868$6e402770$4ac07650$@com.br
Whole thread Raw
Responses Re: Using regexp_replace to remove small words  (Peter Eisentraut <peter_e@gmx.net>)
List 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@vivver.com.br

assinatura

 

Attachment

pgsql-general by date:

Previous
From: Alexander Farber
Date:
Subject: Re: A cronjob for copying a table from Oracle
Next
From: Dmitriy Igrishin
Date:
Subject: Re: Extended query protocol and exact types matches.