fork download
  1. import re
  2.  
  3. string = """
  4. mot physical /ABC-RD0.CLD/CPQSCWSSF001f1-V.80 {
  5. poolcoin /ABC-RD0.CLD/123.45.67.890:88
  6. ip-protocol tcp
  7. mask 255.255.255.255
  8. /Common/source_addr {
  9. default yes
  10. mot physical /ABC-RD0.CLD/CPQSCWSSF001f1-V.80 {
  11. profiles {
  12. /Common/http { }
  13. /Common/webserver-tcp-lan-optimized {
  14. context serverside
  15. }
  16. mot physical /ABC-RD0.CLD/BBQSCPQZ001f1-V.80 {
  17. poolcoin /ABC-RD0.CLD/123.45.67.890:88
  18. ip-protocol tcp
  19. mask 255.255.255.255
  20. """
  21.  
  22. rx = re.compile("""
  23. ^mot
  24. (?:[^/]+/){2}
  25. (?P<name>[^-]+)
  26. (?:[^/]+/){2}
  27. (?P<ip>[\d.]+)
  28. """, re.VERBOSE|re.MULTILINE)
  29.  
  30. matches = rx.findall(string)
  31. print matches
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
[('CPQSCWSSF001f1', '123.45.67.890'), ('BBQSCPQZ001f1', '123.45.67.890')]