| From: | Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr> | 
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org | 
| Subject: | Regular Expression Matching problem... | 
| Date: | 2006-01-04 14:08:45 | 
| Message-ID: | 1136383726.8868.27.camel@localhost.localdomain | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-sql | 
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(dot)splivalo(at)mobart(dot)hr
"I can do it quick, I can do it cheap, I can do it well. Pick any two."
| From | Date | Subject | |
|---|---|---|---|
| Next Message | A. Kretschmer | 2006-01-04 14:50:31 | Re: Regular Expression Matching problem... | 
| Previous Message | Richard Huxton | 2006-01-04 09:21:22 | Re: Loading lots of data in a SQL command |