I'm trying to use regex and I have a limit for input numbers, I want them to be less or equal to 255:
def validate(ip):
try:
x = re.search(r"^(\d+)\.(\d+)\.(\d+)\.(\d+)$", ip.strip())
for pot in x.groups():
if int(pot) <= 255:
return True
else:
return False
except:
return False
validate('64.128.256.512')
well the problem is when I use a for loop, and using return, it checks only for one group of number (I mean the first one 64) and ignores the other, so the result will be True, but what I expect is False.