Skip site navigation (1) Skip section navigation (2)

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
Message-ID: (view raw, whole thread or download thread mbox)
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


pgsql-general by date

Next:From: Sam MasonDate: 2009-03-18 17:15:46
Subject: Re: Accent insensitive search?
Previous:From: Thom BrownDate: 2009-03-18 16:53:40
Subject: Re: Accent insensitive search?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group