fork download
  1. import re
  2.  
  3. pattern = r"Routing for Networks:\n((?:(?:\d{1,3}\.){3}\d{1,3}/\d+\n)+)(?=Routing)"
  4.  
  5. s = ("Routing for Networks:\n"
  6. "0.0.0.0/32\n"
  7. "5.6.4.3/24\n"
  8. "2.3.1.4/32\n"
  9. "Routing Information Sources:\n"
  10. "Gateway Distance Last Update\n"
  11. "192.168.61.100 90 00:33:51\n"
  12. "192.168.61.103 90 00:33:43")
  13.  
  14. m = re.search(pattern, s)
  15. if m:
  16. print([s for s in m.group(1).split("\n") if s])
Success #stdin #stdout 0.03s 9592KB
stdin
Standard input is empty
stdout
['0.0.0.0/32', '5.6.4.3/24', '2.3.1.4/32']