fork download
  1. import re
  2.  
  3. pattern = r"\bsays to (.*(?:\n(?!\(\d|---).*?)*?)\s*\n(?:\(\d|---)"
  4.  
  5. text = ("(2021-07-04 11:58:43 PM BST) \n"
  6. "--- \n"
  7. "len wee zim (Tradition (US) ) says to yohan sen \n"
  8. "[[:Conversations will be recorded and may be monitored by the participants and\n"
  9. "their employers:]] Hi yohan \n"
  10. " \n"
  11. " \n\n"
  12. "(2021-07-05 12:04:42 AM BST) \n"
  13. "--- \n"
  14. "len wee zim (Tradition (US) ) says to yohan sen \n"
  15. "okay -5 / 0 \n"
  16. " \n"
  17. " \n\n"
  18. "(2021-07-05 12:09:41 AM BST) \n"
  19. "--- \n"
  20. "len wee zim (Tradition (Asia)) says to yohan sen \n"
  21. "yes -5 / 0 TN -- / +2.5 \n"
  22. " \n"
  23. " \n"
  24. "--- \n"
  25. " \n"
  26. "* * *\n\n"
  27. "Processed by wokl Archive for son malab | 2021-07-05 12:26:44 AM\n"
  28. "BST ")
  29.  
  30. text = re.findall(pattern, text)
  31. print(text)
Success #stdin #stdout 0.04s 9508KB
stdin
Standard input is empty
stdout
['yohan sen  \n[[:Conversations will be recorded and may be monitored by the participants and\ntheir employers:]] Hi yohan', 'yohan sen  \nokay -5 / 0', 'yohan sen  \nyes -5 / 0 TN -- / +2.5']