fork download
  1. import re
  2. p = re.compile(r"([\d\W]+)\n.*\[(.*)\].*\n.*", re.MULTILINE | re.UNICODE)
  3. test_str = u"""00:00:05,233 --> 00:00:08,133
  4. GAT[xd]fES: Amelia Earhart
  5. is on one of the final legs
  6.  
  7. 00:00:05,333 --> 00:00:08,433
  8. [xd]fES: Amelia Earhart
  9. is on one of the final legs
  10. """
  11.  
  12. subst = r"\1 \2"
  13. result = re.sub(p, subst, test_str)
  14. print result
Success #stdin #stdout 0.01s 7736KB
stdin
Standard input is empty
stdout
00:00:05,233 --> 00:00:08,133 xd

00:00:05,333 --> 00:00:08,433 xd