0

How do i match a domain from each of the strings below using python regex. In this case s1 is invalid becaulse .local is not a good valid tld

s1 = '220 Exng-CAS1.aldanube.local Microsoft , 16 Feb 2016 14:52:24 +0400' # ignore this

# catch all this 
s2 = '220 mail6.mithi.com' 
s3 = '220 news-letter.music.jp unknown'
s3 = '220 nice .music.co.uk Welcome to the server. 16 Feb 2016 14:52:24 +0400'

>>> import re
>>> r = re.match('[a-zA-Z0-9\-]+\.', s1)
>>> r.group()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'group'
Jide Koso
  • 415
  • 5
  • 17

0 Answers0