title: Extracting sections and subsections from list using regex
body: <p>I have a list which I'm extracting from text file via pdfplumber:</p>
  <pre><code>data=['1.1  SUMMARY \n', ' \n', 'A.  Furnish and install: \n', '1.  Soffit support framing. \n', '2.  Universal grid system. \n', '3.  Steel mesh infill. \n', ' \n', 'B.  Perform all drilling and cutting in miscellaneous metal items required for the \n', 'attachment of other items. \n', ' \n', 'C.  Perform all shop painting for all surfaces of exposed to view galvanized and non-\n', 'galvanized metals, and post-erection touch-up of shop prime coat, using the same \n', 'material as shop- prime coating. \n', ' \n', 'D.  Perform application of liquid zinc touch-up to all welds of galvanized steel items \n', 'furnished hereunder. \n', ' \n']
  </code></pre>
  <p><strong>I want to extract A,B,C and D (section) from the list and then corresponding sub sections (if any like 1,2,3 etc.) and some mapping which tells me that section has sub sections.</strong></p>
  <p>Logic is whenever a <code>\n</code> is present as element of list, next element is always the section. And for sub sections, there is no pattern but it will most likely start with number as you can see. I want the output free of new line <code>\n</code>.</p>
  <p>For example, one list for section :</p>
  <pre><code>['A.  Furnish and install:','B.  Perform all drilling and cutting in miscellaneous metal items required for the attachment of other items.','C.  Perform all shop painting for all surfaces of exposed to view galvanized and non-galvanized metals, and post-erection touch-up of shop prime coat, using the same material as shop- prime coating. ','D.  Perform application of liquid zinc touch-up to all welds of galvanized steel items furnished hereunder. ']
  </code></pre>
  <p>and subsections as well :</p>
  <pre><code>['1.  Soffit support framing.', '2.  Universal grid system.', '3.  Steel mesh infill.']
  </code></pre>
  <p>Any kind of mapping works for me to know which subsection belongs to which section. (In this case, we have only 1 subsection for 1st section)</p>
  <p>Currently I have tried spliting <code>re.split(&quot;\n[\s]+\n&quot;,data)</code> which gives me result as</p>
  <pre><code>['1.1  SUMMARY ', ' A.  Furnish and install: \n 1.  Soffit support framing. \n 2.  Universal grid system. \n 3.  Steel mesh infill. ', ' B.  Perform all drilling and cutting in miscellaneous metal items required for the \n attachment of other items. ', ' C.  Perform all shop painting for all surfaces of exposed to view galvanized and non-\n galvanized metals, and post-erection touch-up of shop prime coat, using the same \n material as shop- prime coating. ', ' D.  Perform application of liquid zinc touch-up to all welds of galvanized steel items \n furnished hereunder. ', '']
  </code></pre>
  <p>But this has two downsides. First being <code>\n</code> is present in all sections including the ones which doesn't have any sub section and also if we start removing the <code>\n</code>, then we won't know if that section has any sub section.</p>