fork download
  1. import re
  2.  
  3. regex = r"^currency=(\S+)(?:\n.*)*?\n\[@(\d+)"
  4.  
  5. s = ("[Namex]\n"
  6. "Name=jsdjsk\n"
  7. "value=dfdfdf\n"
  8. "currency=dollor\n"
  9. "market=sfdsf\n"
  10. "endvalue=xyz\n"
  11. "[@1234#feagbdvsdf]\n"
  12. "[Namey]\n"
  13. "Name=jsdjsk\n"
  14. "value=dfdfdf\n"
  15. "currency=\n"
  16. "endvalue=xyz\n"
  17. "[@5777#feagbdvsdf]\n"
  18. "[Namez]\n"
  19. "Name=jsdjsk\n"
  20. "currency=euro\n"
  21. "market=sfdsf\n"
  22. "[@98766#feagbdvsdf]")
  23.  
  24. print(re.findall(regex, s, re.MULTILINE))
Success #stdin #stdout 0.03s 27744KB
stdin
Standard input is empty
stdout
[('dollor', '1234'), ('euro', '98766')]