lines = """line 1line 2line 3 line 4 line 5line 6""" import re print re.match(r'(.*)(?=\n{2})', lines, re.DOTALL).groups()
Standard input is empty
('line 1\nline 2\nline 3',)
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!