fork download
  1. import re
  2.  
  3. regex = r"^SONG\b.*\r?\n((?:(?![A-Z][A-Z ]*$).*\r?\n)*)\s*"
  4.  
  5. test_str = ("And I lie listening awake? \n"
  6. "SONG \n"
  7. "You are as gold \n"
  8. "The half-opened flowers \n"
  9. "For your face is as fair as rain, \n"
  10. "Yet as rain that lies clear \n"
  11. "Casts light for a shadow. \n"
  12. "AT BAIA \n"
  13. "I should have thought")
  14.  
  15. print (re.findall(regex, test_str, re.MULTILINE))
Success #stdin #stdout 0.02s 9560KB
stdin
Standard input is empty
stdout
['You are as gold    \nThe half-opened flowers    \nFor your face is as fair as rain,    \nYet as rain that lies clear    \nCasts light for a shadow.    \n']