fork download
  1. import re
  2.  
  3.  
  4. input="""don't care
  5. whatever
  6. the following is important
  7. really
  8. I mean it
  9. what preceded was important
  10. but now it's over
  11. don't care
  12. whatever
  13. the following is still important
  14. really
  15. I mean it
  16. what preceded was still important
  17. but now it's over"""
  18.  
  19. print(re.findall("following.*?preceded", input, re.DOTALL))
  20. print(re.findall("[^\n]*following.*?preceded[^\n]*", input, re.DOTALL))
Success #stdin #stdout 0.05s 9612KB
stdin
Standard input is empty
stdout
['following is important\nreally\nI mean it\nwhat preceded', 'following is still important\nreally\nI mean it\nwhat preceded']
['the following is important\nreally\nI mean it\nwhat preceded was important', 'the following is still important\nreally\nI mean it\nwhat preceded was still important']