fork download
  1. import re
  2. texts = ['Hello there,\nSPLIT\nhow are you?', 'Hello there, SPLIT how are you?',
  3. 'Hello there,\nSPLIT', 'Hello there,\nSPLIT how are you?']
  4. for text in texts:
  5. print(re.split(r'\n?^SPLIT$\n?', text, flags=re.M))
  6.  
  7. for text in texts:
  8. print(re.split(r'(?:^|\n)SPLIT(?:$|\n)', text))
Success #stdin #stdout 0.03s 9380KB
stdin
Standard input is empty
stdout
['Hello there,', 'how are you?']
['Hello there, SPLIT how are you?']
['Hello there,', '']
['Hello there,\nSPLIT how are you?']
['Hello there,', 'how are you?']
['Hello there, SPLIT how are you?']
['Hello there,', '']
['Hello there,\nSPLIT how are you?']