fork(1) download
  1. import re
  2. s='''A body paragraph about other things. Lorem ipsom and all that
  3.  
  4. **HEADERONE**
  5. - [x] Logged In
  6. - [ ] Logged Out
  7. - [x] Spun Around
  8. - [x] Did the hokey pokey
  9.  
  10. Maybe a link here www.go_ogle.com
  11.  
  12. **HEADERONE**
  13. - [ ] NOT Logged In
  14. - [ ] Logged Out
  15. - [x] Spun Around
  16. - [x] Did the hokey pokey
  17.  
  18. Another list that isn't important
  19. - [ ] Thing one
  20. - [ ] Thing two
  21. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo '''
  22. res = []
  23. tmp = []
  24. inblock = False
  25. for line in s.split('\n'):
  26. if line == '**HEADERONE**':
  27. tmp.append(line.rstrip())
  28. inblock = not inblock
  29. elif inblock and line.startswith("- ["):
  30. tmp.append(line.rstrip())
  31. else:
  32. if len(tmp) > 0:
  33. res.append("\n".join(tmp))
  34. tmp = []
  35. inblock = not inblock
  36.  
  37. print(res)
Success #stdin #stdout 0.04s 9624KB
stdin
Standard input is empty
stdout
['**HEADERONE**\n- [x] Logged In\n- [ ] Logged Out\n- [x] Spun Around\n- [x] Did the hokey pokey', '**HEADERONE**\n- [ ] NOT Logged In\n- [ ] Logged Out\n- [x] Spun Around\n- [x] Did the hokey pokey']