title: Pattern match all text between two sets of pattern
body: <p>I have been trying to create a Regular expression which will match a text block between two sets of pattern but havent been able to do so, at most I just get one line of text.</p>
  
  <p>The text block can contain a sequences of "####" or "****". the number of repetitions is min 2</p>
  
  <p>For example the block text might look like this</p>
  
  <pre><code>************
  test 1
  test 2
  test3
  ############
  x1
  x2
  x3
  ############
  a1
  a2
  a3
  *****
  b1
  b2
  b3
  ***********************
  c1
  c2
  c3
  
  ######################
  
  d1
  d2
  d3
  </code></pre>
  
  <p>Regex match groups should be able to give me all the blocks</p>
  
  <p>result needs to look like this:</p>
  
  <pre><code>Block1:
  
  test 1
  test 2
  test3
  
  block 2:
  
  x1
  x2
  x3
  
  Block 3:
  
  a1
  a2
  a3
  
  block 4:
  b1
  b2
  b3
  
  block 5:
  c1
  c2
  c3
  
  block: 6
  d1
  d2
  d3
  </code></pre>
  
  <p>My effort so far looks looks like this:</p>
  
  <p>Regex: <code>^.*#{2,}\s*(.*)(?=$)|^.*\*{2,}\s*(.*)(?=$)</code></p>
  
  <p>the fiddle with relevant text: <a href="https://regex101.com/r/ghgNbs/1/" rel="nofollow noreferrer">https://regex101.com/r/ghgNbs/1/</a></p>
  
  <p>Any help would be really great!</p>