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

From F.Bissett
Subject Re: regular expressions in query
Date
Msg-id 200521216319.977251@athlon
Whole thread Raw
In response to Re: regular expressions in query  (Jeff Davis <jdavis-pgsql@empires.org>)
Responses Re: regular expressions in query
Re: regular expressions in query
List pgsql-general

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:

 

Warning:pg_query(): Query failed: Error: operator does not exist: boolean ~~* "unknown" HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts.

 

cheers,

Fiona

pgsql-general by date:

Previous
From: Miles Keaton
Date:
Subject: Re: pg_dump dumping data in order? (used to in 7.4 but not now in 8?)
Next
From: Scott Marlowe
Date:
Subject: Re: regular expressions in query