code: def sections(start, end, text, line=True):
      
      if not line:
          return re.findall(start+"(.*?)"+end, text, re.DOTALL)
      
      lines = text.splitlines()
      
      # This is a state-machine with the states MATCHING = True/False
      MATCHING = False
      section_list = []
      sre = re.compile(start)
      ere = re.compile(end)
      
      for line in lines:
          if MATCHING == False:
              if sre.search(line):
                  # Start to take stuff
                  MATCHING = True
                  section = [] 
                  continue
          
          if MATCHING == True:
              if ere.search(line):
                  MATCHING = False
                  section_list.append('\n'.join(section))
              else:
                  section.append(line)
      return section_list
docs: Given the *text* to analyze return the section the start and
      end matchers. If line=True return the lines between the line that
      matches *start* and the line that matches *end* regexps.
  
      If line=False return the text between the matching start and end
      
      The match is in the regexp lingo *ungreedy*.