title: Extracting repeated patterns from a text file in python
body: <p>I am looking to extract all the text between a repeating pattern in a text file. My text file XYZ.txt looks something like this:</p>
  
  <pre><code>Start
  
  This is a great day
  
  End
  
  Start
  This is another great day
  
  End
  
  Start
  This is 3rd great day
  End
  </code></pre>
  
  <p>I am looking extract the all the text between every start and End, my output should be like:</p>
  
  <pre><code>This is a great day
  This is another great day
  This is 3rd great day
  </code></pre>
  
  <p>and I am looking to save all the outputs as separate HTML file. The code that I am using is as follows:</p>
  
  <pre><code>import re
  with open('XYZ.txt') as myfile:
      content = myfile.read()
  
  text = re.search(r'Start\n.*?End', content, re.DOTALL).group()
  
  print(text)
  </code></pre>
  
  <p>But code above only prints the first line. Not sure how I can print all the values between the pattern and save them as seperate html files. I would really appreciate any directions.</p>
  
  <p>Thank You</p>