title: How to match and extract section number and title in python?
body: <p>I want to match and extract the section and subsection numbers and titles in any of the following formats:</p>
  <pre><code>section
  1 section
  2. section
  2.1 subsection
  2.1.1 subsection
  2.1.1. subsection
  2.1.1. subsection multiple words less than 40 chars
  </code></pre>
  <p>I tried</p>
  <pre><code>^(\d{1,3}?(\.?\d{1,3}?\.?)*)?\s*(\w*)$
  </code></pre>
  <p>It doesn't match the second one. I also prefer to have two desired groups (the section number and section title)</p>