I am trying to write a function that loops through a .txt file of a books and identifies chapters. I am using the appearance of more than one \n in a row followed by one line of non \n text to signify a new chapter. How would you guys structure the loops to do this? I personally am using python, but you should feel free to keep your answers as abstract as possible.
chapters = filter(None,map(str.strip,text.split("\n\n")))
you could also do it with re using Stevens answer from the comments