fork download
  1. import re
  2.  
  3. regex = r"(?m)^(\d{2}/\d{2}/\d{4})\n(.*?)(?=\n\d{2}/\d{2}/\d{4}$|\nSome Delimiter|\Z)"
  4.  
  5. test_str = ("Text Starts\n"
  6. "23/01/2018\n"
  7. "Something here. It was a crazy day.\n"
  8. "Believe me.\n"
  9. "02/02/2018\n"
  10. "Another thing happens.\n"
  11. "Some Delimiter\n"
  12. "20/02/2017\n"
  13. "Text here\n"
  14. "21/02/2017\n"
  15. "Another text.\n"
  16. "Here.\n"
  17. "End Section\n"
  18. "...text continues...")
  19.  
  20. print(re.findall(regex, test_str, re.DOTALL))
  21.  
  22.  
Success #stdin #stdout 0.02s 6900KB
stdin
Standard input is empty
stdout
[('23/01/2018', 'Something here. It was a crazy day.\nBelieve me.'), ('02/02/2018', 'Another thing happens.'), ('20/02/2017', 'Text here'), ('21/02/2017', 'Another text.\nHere.\nEnd Section\n...text continues...')]