fork download
  1. import re
  2.  
  3.  
  4. myconvo = """speaker1: hello
  5.  
  6. speaker2: hello (clears throat), let me show you something Ted Cruz said last week
  7.  
  8. (begin audio clip)
  9.  
  10. Ted Cruz (R-TX): My dad did not shoot JFK, why do people keep saying that?
  11.  
  12. (end audio clip)
  13.  
  14. speaker1: now isn't that interesting"""
  15.  
  16.  
  17. regex = r"\r?\n[^\S\r\n]*[([].+[)\]](?:\r?\n(?![^\S\r\n]*[\[\]()]).*)*\r?\n[^\S\r\n]*[\{(].+\n"
  18. result = re.sub(regex, "", myconvo)
  19. print (result)
  20.  
  21.  
  22.  
Success #stdin #stdout 0.02s 9528KB
stdin
Standard input is empty
stdout
speaker1: hello

          speaker2: hello (clears throat), let me show you something Ted Cruz said last week

          speaker1: now isn't that interesting