title: I need a python REGEX to split a file by delimiters (begin, end) that can have multiple occurences
body: <p>I am using Python. I would like to split a file that contains n sections by using the delimiters "BEGIN" and "END".</p>
  
  <p>The file contains:</p>
  
  <pre><code>BEGIN
  ABC ABC ABC
  END
  BEGIN
  XYZ
  XYZ
  END
  BEGIN
  A B C
  END
  </code></pre>
  
  <p>With the file above, I would like to have as output:</p>
  
  <p>file 1:</p>
  
  <pre><code>BEGIN
  ABC ABC ABC
  END
  </code></pre>
  
  <p>file 2:</p>
  
  <pre><code>BEGIN
  XYZ
  XYZ
  END
  </code></pre>
  
  <p>file 3:</p>
  
  <pre><code>BEGIN
  A B C
  END
  </code></pre>
  
  <p>I think this can be done with a REGEX but I haven't been able to find the pattern that will identify the 3 groups (BEGIN ... END) in the example above.</p>
  
  <p>I would be very grateful if you could help me.</p>
  
  <p>Thank you</p>