title: How to allow regular expression to return empty string
body: <p>I have a series of text files to parse which may or may not contain any one of a collection of headers, and then lines of data or comment below that header. All header groups are preceded by a double line break.</p>
  
  <p>I am seeking a regular expression that will return an empty string if it sees a header followed immediately by a double line break. I need to differentiate whether a document has that header with no content, or does not have that header at all.</p>
  
  <p>For example, here are portions of two documents:</p>
  
  <pre><code>Dogs
  Spaniel
  Beagle
  
  Birds
  Parrot
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Dogs
  
  Amphibians
  Frogs
  Salamanders
  </code></pre>
  
  <p>I would like a regex that would return <code>Spaniel\nBeagle</code> in the first document, and an empty string for the second.</p>
  
  <p>The closest I have been able to find is (in Python syntax) <code>expr = re.compile("Dogs(.+?|)?\n\n, re.DOTALL)</code>. This returns the correct value for the first, but in the second case it returns <code>\n\nAmphibians\nFrogs\nSalamanders</code>. The second question mark and the pipe do not do what I had hoped.</p>
  
  <p>I am handling this by program logic right now, searching for <code>Dogs\n\n</code> and only returning contents if that regex is not found, but it is unsatisfying because nothing beats the feeling of a single regular expression doing the job.</p>
  
  <p>So: is there a regex that will match the second document, and return <code>""</code>?</p>