On Fri, 18 Feb 2005 13:14:28 -0500 rbt <[EMAIL PROTECTED]> wrote: > Is it possible to use re.compile to exclude certain numbers? For > example, this will find IP addresses: > > ip = re.compile('\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}') > > But it will also find 999.999.999.999 (something which could not > possibly be an IPv4 address). Can re.compile be configured to filter > results like this out?
Try this one: re.compile(r'\b%s\b' % r'\.'.join(['(?:(?:2[0-4]|1\d|[1-9])?\d|25[0-5])']*4)) -- Denis S. Otkidach http://www.python.ru/ [ru] -- http://mail.python.org/mailman/listinfo/python-list