title: Python multi-line regex greedy group
body: <p>I'm attempting to parse the following example text in Python:</p>
  
  <pre><code>Foo 1
  foo1Text
  
  Bar 
  bar1Text
  
  Baz 
  baz1Text
  
  Foo 2
  foo2Text
  
  Bar 
  bar2Text
  
  Baz 
  baz2Text
  
  # and so on up to Foo/Bar/Baz N
  </code></pre>
  
  <p>Now, the regex I'm using is:</p>
  
  <pre><code>([\S ]+)(\n*)([\s\S]*?)Bar([\s\S]*?)Baz([\s\S]*?)
  </code></pre>
  
  <p>Now - what I'd like to do is lift out the text relevant to <code>foo</code>/<code>bar</code>/<code>baz</code>. However, with the lazy qualifier on the end of the regex, <code>?</code> the expression stops short and misses the <code>baz2text</code>. Conversely, making it greedy matches everything else as part of the last group.</p>
  
  <p>I'd prefer to not use a numeric qualifier if possible and broadly match things based on:</p>
  
  <pre><code>{title}
  {stuff about title}
  
  Bar
  {stuff about Bar}
  
  Baz
  {stuff about Baz}
  </code></pre>
  
  <p>So I may iterate through each match and extract groups accordingly. Please note, I've not phrased this around extracting concrete output. I'm mostly interested in getting the regex 'groups' so they represent: <code>{title}</code>, <code>{stuff about title}</code>, <code>{stuff about bar}</code>, <code>{stuff about Baz}</code></p>
  
  <p>I was putzing around with <a href="https://regex101.com/r/fLRZwM/1" rel="nofollow noreferrer">regex101</a> to see if I could determine the right incantation to no avail. </p>
  
  <p>This is one of those problems where its easy enough to do manually. But then I wouldn't learn anything! :) I'd love to know if there's some cleaner mechanism / strategy I should be using here.</p>
  
  <p>Thanks much</p>