I have a problem with one task:
I have output from cisco hw.
IP access list 100
10 permit igmp any any
20 deny any any
IP access list 200
10 permit ip 192.168.1.1/32
20 permit ip 192.168.2.1/32 any
30 permit ip 192.168.3.3/32 any
40 deny any any
The task is to make a dict with access list number as key and access list rule number as value.
acl_dict = {'100' : '10', '100' : '20','200': '10', '200': '20', '200': '30', '200': '40'}
I have written a regex:
rx = re.compile("""
list\s(.*)[\n\r]
\s{4}(\d{1,3}).+$
""",re.MULTILINE|re.VERBOSE)
for match in rx.finditer(text):
print (match.group(1))
print (match.group(2))
But is shows only number from first two strings (100 and 10) I need to modify somehow regex to match all numbers to make needed dict. Can anyone help ?