I'm using a regex to find hostname in a string which match all the possible combinations but not able to construct one.
names = ['www.google.com.in','w.stack.in','www.code31ws.com','google.com','ww.sample.co']
regex = '(w{3}?\.?)?[\w?-]+\.(com|in|edu|co)'
for i in range(len(ips)):
reg = re.search(regex,ips[i])
if reg:
print "true {}".format(i)
else:
print "false {}".format(i)
Result it:
true 0
true 1
true 2
true 3
true 4
Want that it should not match:
w.stack.in
ww.sample.com