fork download
  1. import re
  2.  
  3. text = """2018-01-09 04:50:25,226 [18] INFO messages starts here line1
  4. line2 above error continued in next line
  5. 2018-01-09 04:50:29,226 [18] ERROR messages starts here line1
  6. line2 above error continued in next line
  7. 2018-01-09 05:50:29,226 [18] ERROR messages starts here line1
  8. line2 above error continued in next line"""
  9.  
  10. matches = re.findall(r'(\d{4}(?:-\d{2}){2}\s\d{2}(?::\d{2}){2})(,\d+[^\]]+\])\s(INFO|ERROR)\s([\S\s]+?)(?=\r?\n\d{4}(?:-\d{2}){2}|$)', text)
  11.  
  12. print(matches)
Success #stdin #stdout 0.04s 64664KB
stdin
Standard input is empty
stdout
[('2018-01-09 04:50:25', ',226 [18]', 'INFO', 'messages starts here line1\nline2 above error continued in next line'), ('2018-01-09 04:50:29', ',226 [18]', 'ERROR', 'messages starts here line1\nline2 above error continued in next line'), ('2018-01-09 05:50:29', ',226 [18]', 'ERROR', 'messages starts here line1\nline2 above error continued in next line')]