import re


input="""don't care
whatever
the following is important
really
I mean it
what preceded was important
but now it's over
don't care
whatever
the following is still important
really
I mean it
what preceded was still important
but now it's over"""

print(re.findall("following.*?preceded", input, re.DOTALL))
print(re.findall("[^\n]*following.*?preceded[^\n]*", input, re.DOTALL))