I am trying to validate an IP address. Following is the code. Can anyone please tell me what is wrong in the code?
import re
ip = '355.4'
m = re.match('^((?:1?\d{0,2}|2[0-4]\d{1}|25[0-5]).){3}(?:1?\d{0,2}|2[0-4]\d{1}|25[0-5])$', ip)
if m:
print "correct"
print m.groups()
else:
print "wrong"
According to the IP given, it should print wrong as output but it prints correct ('4',) as the output.