X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id B74209DC944 for ; Wed, 4 Jan 2006 10:08:50 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23905-03 for ; Wed, 4 Jan 2006 10:08:54 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) by postgresql.org (Postfix) with ESMTP id 9AE3B9DC9A0 for ; Wed, 4 Jan 2006 10:08:48 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by pjetlic.mobart.hr (Postfix) with ESMTP id D189017A44 for ; Wed, 4 Jan 2006 15:08:48 +0100 (CET) Received: from pjetlic.mobart.hr ([127.0.0.1]) by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 05228-02-5 for ; Wed, 4 Jan 2006 15:08:48 +0100 (CET) Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by pjetlic.mobart.hr (Postfix) with ESMTP id B051117458 for ; Wed, 4 Jan 2006 15:08:48 +0100 (CET) Subject: Regular Expression Matching problem... From: Mario Splivalo Reply-To: mario.splivalo@mobart.hr To: pgsql-sql@postgresql.org Content-Type: text/plain Organization: Mob-Art Date: Wed, 04 Jan 2006 15:08:45 +0100 Message-Id: <1136383726.8868.27.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by OpenSource AV+AS Mail Server X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.04 required=5 tests=[AWL=0.040] X-Spam-Score: 0.04 X-Spam-Level: X-Archive-Number: 200601/14 X-Sequence-Number: 23803 I have a table containing regular expresion patterns for matching phone numbers with the mobile operators. For instance, my phone number is '+385911234567', and the regexp for this mobile operator is: "^\+38591\d{7}$". Now, when I do a regexp match in a single select, it behaves as expected: octopussy2=# select '+385911234567' ~ '^\\+38591\\d{7}$'; ?column? ---------- t (1 row) Now, as I've mentioned, I have a table with operators and their patterns for phone numbers: octopussy2=# select * from operators; operator_id | operator_name | operator_phonenumber_pattern -------------+---------------+------------------------------ 1 | FreeSMSC | ^\\+38590\\d{6,7}$ 2 | VipNet | ^\\+38591\\d{7}$ 3 | T-Mobile | ^\\+3859[9|8]\\d{6,7}$ 4 | Tele2 | ^\\+38595\\d{7}$ (4 rows) Now, if I construct my query like this: octopussy2=# select '+385911234567', operator_phonenumber_pattern, '+385911234567' ~ operator_phonenumber_pattern from operators; ?column? | operator_phonenumber_pattern | ?column? ---------------+------------------------------+---------- +385911234567 | ^\\+38590\\d{6,7}$ | f +385911234567 | ^\\+38591\\d{7}$ | f +385911234567 | ^\\+3859[9|8]\\d{6,7}$ | f +385911234567 | ^\\+38595\\d{7}$ | f (4 rows) Why do I get all the "f"'s? I tought that the operator_id 2 should return "t", esp. when I wrote the first query it seems that the regex match was ok. Or I can't do regexp matching from the table columns? Mike -- Mario Splivalo Mob-Art mario.splivalo@mobart.hr "I can do it quick, I can do it cheap, I can do it well. Pick any two."