# HG changeset patch # User Richard Penman # Date 1484897104 -28800 # Node ID ccd653a5426394da1f0e07d6739fbea341178145 # Parent b4273400685e11334aecbee8ec589d7e51c718b7 support multiple matches in regex diff -r b4273400685e -r ccd653a54263 setup.py --- a/setup.py Tue Jan 10 09:33:41 2017 +0800 +++ b/setup.py Fri Jan 20 15:25:04 2017 +0800 @@ -1,7 +1,7 @@ import sys, os import setuptools -version = '0.6.3' +version = '0.6.5' setuptools.setup( name='python-whois', diff -r b4273400685e -r ccd653a54263 whois/parser.py --- a/whois/parser.py Tue Jan 10 09:33:41 2017 +0800 +++ b/whois/parser.py Fri Jan 20 15:25:04 2017 +0800 @@ -125,17 +125,19 @@ for attr, regex in list(self._regex.items()): if regex: values = [] - for value in re.findall(regex, self.text, re.IGNORECASE): - value = value.strip() - if value and isinstance(value, basestring) and not value.isdigit() and '_date' in attr: - # try casting to date format - value = cast_date( - value, - dayfirst=self.dayfirst, - yearfirst=self.yearfirst) - if value and value not in values: - # avoid duplicates - values.append(value) + for data in re.findall(regex, self.text, re.IGNORECASE): + matches = data if isinstance(data, tuple) else [data] + for value in matches: + value = value.strip() + if value and isinstance(value, basestring) and not value.isdigit() and '_date' in attr: + # try casting to date format + value = cast_date( + value, + dayfirst=self.dayfirst, + yearfirst=self.yearfirst) + if value and value not in values: + # avoid duplicates + values.append(value) if values and attr in ('registrar', 'whois_server', 'referral_url'): values = values[-1] # ignore junk if len(values) == 1: