fork download
  1. import re
  2.  
  3. parsed = re.compile(r'^(\S*)\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s*(\S*)\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s*(\S*)$', re.M)
  4. text = r'''Number of neighbors: 2
  5.  
  6. AP Name AP IP Neighbor Name Neighbor IP Neighbor Port
  7. -------------------------------------------------------------------------------------------------------------------------------------------------------------
  8. ap001-w101-a91 1.2.3.4 sw0002-sw04-C22 2.3.4.5 GigabitEthernet1/0/1
  9. ap003-w4203-a28 2.3.2.2 sw002-sw02-c22.switch.local 3.2.3.2 GigabitEthernet1/0/17'''
  10.  
  11. print(parsed.findall(text))
  12.  
Success #stdin #stdout 0.13s 15520KB
stdin
Standard input is empty
stdout
[('ap001-w101-a91', '1.2.3.4', 'sw0002-sw04-C22', '2.3.4.5', 'GigabitEthernet1/0/1'), ('ap003-w4203-a28', '2.3.2.2', 'sw002-sw02-c22.switch.local', '3.2.3.2', 'GigabitEthernet1/0/17')]