>>> 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Support Desk Sent: Monday, June 30, 2008 10:54 PM To: python-list@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.
-- http://mail.python.org/mailman/listinfo/python-list