Rob Wolfe wrote: ... > def filter(adr): # note that "filter" is a builtin function also > import re > > allow = re.compile(r'.*(?<!\.com)\.my(>|$)') # negative lookbehind > deny = re.compile(r'.*\.com\.my(>|$)') > cnt = 0 > if deny.search(adr): cnt += 1 > if allow.search(adr): cnt += 1 > return cnt
Which makes the 'deny' code here redundant so in this case the function could be reduced to: import re def allow(adr): # note that "filter" is a builtin function also allow = re.compile(r'.*(?<!\.com)\.my(>|$)') # negative lookbehind if allow.search(adr): return True return False Though having the explicit allow and deny expressions may make what's going on clearer than the fairly esoteric negative lookbehind. -- http://mail.python.org/mailman/listinfo/python-list