0

The below code does not match in all the if statements.
I would like to know what makes the if statement match in the 2nd for loop, but not in the 1st and 3rd for loop?

for line in x:
    if '0.0.0.0/0' and 'A' in line:
        y = re.findall(r'\b\d{2,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b', str(line))

These are the lines in x.
No lines get matched but correct value still goes into y because it is the only one which matches regex.
0 ADS 0.0.0.0/0 41.222.225.255 0
1 ADC 41.222.225.255/32 197.242.206.100 pppoe-out1 0
2 ADC 172.20.0.0/24 172.20.0.1 LAN 0

gw = []
for line in x:
        if y and '/32' in line:
        gw.append(str(line).split()[4])

Line in x which gets matched as expected.
I have not shown the other lines which do not get matched
1 ADC 41.222.225.255/32 197.242.206.100 pppoe-out1 0

mtu = []
for line in x:
    print line
    if str(gw) in line:
        mtu.append(re.findall(r'actual-mtu=\d{1,4}\s*', str(x)))

Line in x which does not get matched.
13 R name=pppoe-out1 type=pppoe-out mtu=1480 actual-mtu=1480 fast-path=yes last-link-down-time=jun/15/2017 20:37:43 last-link-up-time=jun/15/2017 20:37:44 link-downs=11

Kevin Crick
  • 187
  • 1
  • 2
  • 8

0 Answers0