title: Extract data with regular expresion with python
body: <p>I am trying to extract data from a txt file (see a sample text below) using python. Take into account that the title can be in one single line, split into two lines or even split with a blank line in the middle (TITLE1).</p>
  <p>What I would like to achieve is to extract the information to store in a table like this:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Code</th>
  <th>Title</th>
  <th>Opening date</th>
  <th>Deadline</th>
  <th>Budget</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>TITLE-SDFSD-DFDS-SFDS-01-01</td>
  <td>This is the title 1 that is split in two lines with a blank line in the middle</td>
  <td>15-Apr-21</td>
  <td>26-Aug-21</td>
  <td>EUR 20.00 million</td>
  </tr>
  <tr>
  <td>TITLE-SDFSD-DFDS-SFDS-01-02</td>
  <td>This is the title2 in one single line</td>
  <td>15-Mar-21</td>
  <td>17-Aug-21</td>
  <td>EUR 15.00 million</td>
  </tr>
  <tr>
  <td>TITLE-SDFSD-DFDS-SFDS-01-03</td>
  <td>This is the title3 that is too long and takes two lines</td>
  <td>15-May-21</td>
  <td>26-Sep-21</td>
  <td>EUR 5.00 million</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I manage to identify the &quot;codes titles&quot; with this piece of code:</p>
  <pre><code>import re
  
  with open('doubt2.txt','r', encoding=&quot;utf-8&quot;) as f:
      f_contents = f.read() 
      
  pattern = re.compile(r'TITLE-.+-[0-9]{2}-[0-9]{2}(?!,)\S{1}')
  matches = pattern.finditer(f_contents)
  
  for match in matches:
      print(match)
  </code></pre>
  <p>And I get this result:</p>
  <pre><code>&lt;re.Match object; span=(160, 188), match='TITLE-SDFSD-DFDS-SFDS-01-01:'&gt;
  &lt;re.Match object; span=(669, 697), match='TITLE-SDFSD-DFDS-SFDS-01-02;'&gt;
  &lt;re.Match object; span=(1066, 1094), match='TITLE-SDFSD-DFDS-SFDS-01-03:'&gt;
  </code></pre>
  <p>My doubt is how to get the information that I identified with the regular expression and extract the rest of the data. Can you help me, please?</p>
  <blockquote>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam id diam
  posuere, eleifend diam at, condimentum justo. Pellentesque mollis a
  diam id consequat.</p>
  <p>TITLE-SDFSD-DFDS-SFDS-01-01: This is the title 1 that</p>
  <p>is split into two lines with a blank line in the middle</p>
  <p>Conditions Pellentesque blandit scelerisque pellentesque. Sed nec quam
  purus. Quisque nec tellus sed neque accumsan lacinia sit amet sit amet
  tellus. Etiam venenatis nibh vel pellentesque elementum. Nullam eget
  tortor quam. Morbi sed leo et arcu aliquet luctus.</p>
  <p>Opening date 15 Apr 2021</p>
  <p>Deadline 26 Aug 2021</p>
  <p>Indicative budget: The total indicative budget for the topic is EUR
  20.00 million.</p>
  <p>TITLE-SDFSD-DFDS-SFDS-01-02; This is the title2 in one single line</p>
  <p>Conditions Cras egestas consectetur sapien at dignissim. Maecenas
  commodo purus nibh, a tempus augue vestibulum feugiat. Vestibulum
  dolor neque, sagittis ut tortor et, lobortis faucibus quam.</p>
  <p>Opening date 15 March 2021</p>
  <p>Deadline 17 Aug 2021</p>
  <p>Indicative budget: The total indicative budget for the topic is EUR
  15.00 million.</p>
  <p>TITLE-SDFSD-DFDS-SFDS-01-03: This is the title3 that is too long and takes two lines</p>
  <p>Conditions Cras egestas consectetur sapien at dignissim. Maecenas
  commodo purus nibh, a tempus augue vestibulum feugiat. Vestibulum
  dolor neque, sagittis ut tortor et, lobortis faucibus quam.</p>
  <p>Opening date 15 May 2021</p>
  <p>Deadline 26 Sep 2021</p>
  <p>Indicative budget: The total indicative budget for the topic is EUR
  5.00 million.</p>
  </blockquote>