Below input file has:
ipnetwork:111.0.1.0/255.255.255.0
I am reading this input file using python dictionary like below.
d = {}
with open('inputfile.txt') as f:
for line in f:
if ":" not in line:
continue
key, value = line.strip().split(":", 1)
d[key] = value
for key, value in d.iteritems():
if key == 'ipnetwork':
ip = value
Now I need help here to validate the input provided that is.
ipnetwork must be below format like below:
1.2.2.0/255.255.0.0--valid input
111.111.111.0/255.0.0.0 --valid input
256.500.111.0/0.0.0.0 --not valid input since ip does not contain more than 255 number
10.10.aa.1/255.255.255.0 --not valid input since ip address does not contain alphabets