Re: Using regexp_replace to remove small words

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Henrique de Lima Trindade <henrique(at)vivver(dot)com(dot)br>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Using regexp_replace to remove small words
Date: 2010-12-10 22:59:02
Message-ID: 1292021942.9879.8.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On fre, 2010-12-10 at 10:47 -0200, Henrique de Lima Trindade wrote:
> 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.

Here is a start:

select regexp_replace('Tommy Lee Jones', $$\y\w{2,3}\y$$, ' ', 'g' );

If you want to normalize the spaces after the removal and handle
beginning and end of the word, you will need to expand this to cover
those cases, but the example should contain the key ingredients.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message jan 2010-12-10 23:02:20 pg_dump order of rows
Previous Message jan 2010-12-10 22:51:31 pg_dump order of rows