fork download
  1. import re
  2. given_text = '1stline\n2ndline\r3rdline\r\n4thline\r\n\r\nLast Line after an empty line'
  3. print( re.findall('[^\r\n]+', given_text) )
  4. print( re.split(r'\r\n?|\n', given_text) )
  5. print( re.findall(r'[^\r\n\x0B\x0C\x85\u2028\u2029]+', given_text) )
  6. print( re.split(r'\r\n?|[\n\x0B\x0C\x85\u2028\u2029]', given_text) )
  7.  
Success #stdin #stdout 0.02s 9720KB
stdin
Standard input is empty
stdout
['1stline', '2ndline', '3rdline', '4thline', 'Last Line after an empty line']
['1stline', '2ndline', '3rdline', '4thline', '', 'Last Line after an empty line']
['1stline', '2ndline', '3rdline', '4thline', 'Last Line after an empty line']
['1stline', '2ndline', '3rdline', '4thline', '', 'Last Line after an empty line']