Re: regular expressions in query

From: Russ Brown <pickscrape(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: regular expressions in query
Date: 2005-02-13 09:57:58
Message-ID: 420F24A6.9060703@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

elein wrote:
> No doubt someone more adept at perl can write
> this function as a one-liner.
>
> create or replace function just_digits(text)
> returns text as
> $$
> my $innum = $_[0];
> $innum =~ s/\D//g;
> return $innum;
> $$ language 'plperl'
>
> SELECT telephone FROM addresses
> WHERE user_id = 'bob'
> AND just_digits(telephone) = '1115551212';
>
> --elein
>

I've thought about things like this in the past, and a thought that
occurred to me was to add a functional index on just_digits(telephone)
to the table. Would this not allow the above query to use an index while
searching?

--

Russ.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lincoln Yeoh 2005-02-13 11:51:49 Re: regular expressions in query
Previous Message ttina 2005-02-13 08:58:24 Re: problem with thai language==again