Regex trouble

Support Desk mike at ipglobal.net
Thu Sep 24 10:43:00 EDT 2009


I am trying to loop over a dictionary  of phone numbers and using a python
regex to determine if they are long distance or local and then adding them
to their appropriate dictionary, My regex doesn't appear to be working
though.

 

My regex's are these

 

international__iregex=r'^1?(011|001)'  #Anything starting with these
prefixes is International

local__iregex=r'^1?(281|832|713|800)' #anything starting with these are
local

#long distance

ld_regex=r'^1?(281|832|713|800|866|877|011|001|888)'  #any number not
starting with these prefixes is long distance

 

long_distance= {}

My loop:

                for key1,value1 in x.items():

                        if key1 == 'dest':       

                                if not re.search(ld_regex,value1):

                                        long_distance[key1] = value1

                                print long_distance

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090924/d6adb954/attachment-0001.html>


More information about the Python-list mailing list