fork download
  1. import re
  2.  
  3. test_str = ("(a) method in/to one's madness\n"
  4. "(all) by one's lonesome\n"
  5. "(as) tough as (old boot's)\n"
  6. " (at) any moment (now) \n"
  7. "factors (in or into or out) \n"
  8. " right-to-life\n"
  9. "all mouth (and no trousers/action)\n"
  10. "(it's a) small world\n"
  11. " throw (someone) a bone ")
  12.  
  13. regex = r"[^\S\r\n]*\([^()]*\)"
  14. result = "\n".join([x.strip() for x in re.sub(regex, "", test_str).splitlines()])
  15. print (result)
Success #stdin #stdout 0.02s 9524KB
stdin
Standard input is empty
stdout
method in/to one's madness
by one's lonesome
tough as
any moment
factors
right-to-life
all mouth
small world
throw a bone