title: regex: string with optional parts
body: <p>I am trying to parse some docstrings. </p>
  
  <p>An example docstrings is:</p>
  
  <pre><code>Test if a column field is larger than a given value
      This function can also be called as an operator using the '&gt;' syntax
  
      Arguments:
          - DbColumn self
          - string or float value: the value to compare to
              in case of string: lexicographic comparison
              in case of float: numeric comparison
      Returns:
          DbWhere object
  </code></pre>
  
  <p>Both the <code>Arguments</code> and <code>Returns</code> parts are optional. I want my regex to return as groups the description (first lines), the <code>Arguments</code> part (if present) and the <code>Returns</code> part (if present).</p>
  
  <p>The regex I have now is:</p>
  
  <pre><code>m = re.search('(.*)(Arguments:.*)(Returns:.*)', s, re.DOTALL)
  </code></pre>
  
  <p>and works in case all three parts are present but fails as soon as <code>Arguments</code> or the <code>Returns</code>parts are not available. I have tried several variations with the non-greedy modifiers like <code>??</code>but to no avail.</p>
  
  <p><strong>Edit:</strong>  When the <code>Arguments</code> and <code>Returns</code> parts are present, I actually would only like to match the text after <code>Arguments:</code> and <code>Returns:</code> respectively.</p>
  
  <p>Thanks!</p>