title: Extract date from file name with import re in python
body: <p>My file name looks like as follow:</p>
  <pre><code>show_data_paris_12112019.xlsx
  </code></pre>
  <p>I want to extract the date only and I have tried this script:</p>
  <pre><code>date = os.path.basename(xls)
  pattern = r'(?&lt;=_)_*(?=\.xlsx)'
  
  re.search(pattern, date).group(0)
  event_date = re.search(pattern, date).group(0)
  event_date_obj = datetime.strptime (event_date, '%Y%m%d')
  </code></pre>
  <p>but It gives me errors. How can I fix this?</p>
  <p>Thank you.</p>