regex help
Metal Zong
metalzong at 163.com
Mon Jun 30 11:14:13 EDT 2008
>>> import re
>>>
>>> if __name__ == "__main__":
... lst = [281, 713, 832, 1281, 1713, 1832, 2281, 2713, 2832]
... for item in lst:
... if re.match("^1?(?=281)|^1?(?=713)|^1?(?=832)", str(item)):
... print "%d invalid" % item
... else:
... print "%d valid" % item
...
281 invalid
713 invalid
832 invalid
1281 invalid
1713 invalid
1832 invalid
2281 valid
2713 valid
2832 valid
>>>
_____
From: python-list-bounces+metalzong=163.com at python.org
[mailto:python-list-bounces+metalzong=163.com at python.org] On Behalf Of
Support Desk
Sent: Monday, June 30, 2008 10:54 PM
To: python-list at python.org
Subject: regex help
Hello,
I am working on a web-app, that querys long distance numbers from a
database of call logs. I am trying to put together a regex that matches any
number that does not start with the following. Basically any number that
does'nt start with:
281
713
832
or
1281
1713
1832
is long distance any, help would be appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080630/683ade87/attachment-0001.html>
More information about the Python-list
mailing list