Re: regular expressions in query

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: "F(dot)Bissett" <fbissett(at)blueyonder(dot)co(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: regular expressions in query
Date: 2005-02-12 16:54:02
Message-ID: 1108227242.11967.81.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 2005-02-12 at 10:31, F.Bissett wrote:
> On Fri, 11 Feb 2005 19:56:33 -0800, Jeff Davis wrote:
> >Try using the "~" regex matching operator instead of ILIKE.
> >
> >Regards,
> >Jeff Davis
> >
>
>
>
> I still need the ILIKE to compare the returned value with $telephone.
>
>
>
> I have the following PHP to check an input string for non numeric
> characters:
>
>
>
> $tel = ereg_replace('[^[:digit:]]', "", $test); -- $tel then equals
> only the numbers in test.
>
>
>
> This is what I want to be able to do inside the query, but without
> altering the values in the database - to look at the column 'phone',
> see if there are any non-numeric characters and ignore them then
> compare the numbers that are left with $telephone.
>
>
>
> I tried "AND phone ~ '[^[:digit:]]' ILIKE $telephone"
>
> But get the following error:

Try anding them:

where phone ILIKE $telephone AND phone ~ '[.... etc...

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-02-12 17:27:20 Re: regular expressions in query
Previous Message F.Bissett 2005-02-12 16:31:09 Re: regular expressions in query