fork(1) download
  1. import re
  2.  
  3. test_str = u"""
  4. 10
  5. 00:00:33,900 --> 00:00:34,767
  6. Get to Rabaul.
  7. Yeah.
  8.  
  9. 11
  10. 00:00:34,767 --> 00:00:36,033
  11. [Ground rumbling]
  12.  
  13. 12
  14. 00:00:36,033 --> 00:00:37,533
  15. Earthquake. Whoa.
  16. [Children screaming]
  17.  
  18. 13
  19. 00:00:37,533 --> 00:00:39,200
  20. Holy [bleep]
  21.  
  22. 14
  23. 00:00:40,133 --> 00:00:44,333
  24. We heard that your tribe has
  25. found wreckage in the jungles.
  26.  
  27. 70
  28. 00:03:12,800 --> 00:03:14,767
  29. [Airplane engine roars]
  30.  
  31. 71
  32. 00:03:17,200 --> 00:03:20,767
  33. In the last 75 years, there
  34. have been countless dead ends,
  35. """
  36.  
  37. pattern = re.compile(r"(?=\d+:\d+)(.*)(\s|\s.*\s)(?=.*\[).*\[(.*)\]", re.MULTILINE | re.UNICODE)
  38. matches = re.findall(pattern, test_str)
  39.  
  40. for item in matches:
  41. print item[0] + ' ' + item[2]
  42.  
Success #stdin #stdout 0.01s 7736KB
stdin
Standard input is empty
stdout
00:00:34,767 --> 00:00:36,033 Ground rumbling
00:00:36,033 --> 00:00:37,533 Children screaming
00:00:37,533 --> 00:00:39,200 bleep
00:03:12,800 --> 00:03:14,767 Airplane engine roars