fork download
  1. import re
  2.  
  3. text = """unit 3 {
  4. arp-options {
  5. aging-timer 5;
  6. }
  7. family inet4 {
  8. address 2.33.1.2/255.255.255.0;
  9. address 2.33.2.2/255.255.255.0;
  10. address 2.33.3.2/255.255.255.0;
  11. address 2.33.4.2/255.255.255.0;
  12. }
  13. }"""
  14.  
  15. m = re.search(r"family inet4\s*{([^{}]*)}", text)
  16. if m:
  17. res = [x.strip().split()[-1].strip(';') for x in m.group(1).strip().splitlines()]
  18. print(res)
Success #stdin #stdout 0.02s 9528KB
stdin
Standard input is empty
stdout
['2.33.1.2/255.255.255.0', '2.33.2.2/255.255.255.0', '2.33.3.2/255.255.255.0', '2.33.4.2/255.255.255.0']