Re: Accent insensitive search?

From: Thom Brown <thombrown(at)gmail(dot)com>
To: Pedro Doria Meunier <pdoria(at)netmadeira(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Accent insensitive search?
Date: 2009-03-18 17:07:52
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Here's an example of a function I might use (although I haven't actually got
plperl installed, so can't test it myself, but you'll get the idea:

CREATE OR REPLACE FUNCTION unaccent_string(text) RETURNS text AS $$
my ($input_string) = @_;
$input_string =~ s/[âãäåāăą]/a;
$input_string =~ s/[ÁÂÃÄÅĀĂĄ]/A;
$input_string =~ s/[èééêëēĕėęě]/e;
$input_string =~ s/[ĒĔĖĘĚ]/E;
$input_string =~ s/[ìíîïìĩīĭ]/i;
$input_string =~ s/[ÌÍÎÏÌĨĪĬ]/I;
$input_string =~ s/[óôõöōŏő]/o;
$input_string =~ s/[ÒÓÔÕÖŌŎŐ]/O;
$input_string =~ s/[ùúûüũūŭů]/u;
$input_string =~ s/[ÙÚÛÜŨŪŬŮ]/U;
return $input_string;
$$ LANGUAGE plperl;



In response to


Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2009-03-18 17:15:46 Re: Accent insensitive search?
Previous Message Thom Brown 2009-03-18 16:53:40 Re: Accent insensitive search?