regular expressions in query

From: fiona <fbissett(at)blueyonder(dot)co(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: regular expressions in query
Date: 2005-02-11 22:21:26
Message-ID: 420D2FE6.7050508@blueyonder.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

My database table holds phone numbers that may contain characters other
than digits (that's not a problem in itself).

I want to be able to apply a regular expression (to ignore all
characters except digits) to the attribute 'phone' first and then for
the ILIKE to compare
the result to $telephone. I can't find any way of applying the RE to phone.
My current query without the RE is as follows:

SELECT telephone FROM addresses WHERE id = user_id AND phone ILIKE
'%".addslashes($telephone)."%'"
I want to do something like: AND phone([^[:digit:]]) ILIKE $telephone
But this doesn't work.
Any ideas?
--
Get Thunderbird <http://www.mozilla.org/products/thunderbird/>
<http://www.mozilla.org/products/thunderbird/>

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2005-02-11 22:25:06 Re: Hello...
Previous Message Martijn van Oosterhout 2005-02-11 22:21:18 Re: Understanding EXPLAIN ANALYZE output