fork(1) download
  1. import re
  2. teststr= 'chapter 1 Here is a block of text from chapter one. chapter 2 Here is another block of text from the second chapter. chapter 3 Here is the third and final block of text.'
  3. my_result = [x.strip() for x in re.split(r'(?!^)(?=chapter \d)', teststr)]
  4. print( my_result )
  5.  
Success #stdin #stdout 0.02s 9552KB
stdin
Standard input is empty
stdout
['chapter 1 Here is a block of text from chapter one.', 'chapter 2 Here is another block of text from the second chapter.', 'chapter 3 Here is the third and final block of text.']