Re: regular expressions in query - Mailing list pgsql-general

From Russ Brown
Subject Re: regular expressions in query
Date
Msg-id 420F24A6.9060703@gmail.com
Whole thread Raw
In response to Re: regular expressions in query  (elein@varlena.com (elein))
Responses Re: regular expressions in query  (Lincoln Yeoh <lyeoh@pop.jaring.my>)
List 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.

pgsql-general by date:

Previous
From:
Date:
Subject: Re: problem with thai language==again
Next
From: Lincoln Yeoh
Date:
Subject: Re: regular expressions in query