title: Extract a name substring from a filename and store it in a variable in Python
body: <p>I have a tar file whose name I am successfully able to read and store in a variable, </p>
  
  <pre><code>tarname = 'esarchive--Mona-AB-Test226-8037affd-06d1-4c61-a91f-816ec9cb825f-05222017-4.tar'
  </code></pre>
  
  <p>But how do I extract just "Mona" from this file name and store it in a variable?</p>
  
  <p>(The filename structure for the tar file will be same as above for all tar files with the name occuring after "<strong>es-archive--{Name}-AB</strong>" , so a solution which returns any name obeying this format)</p>
  
  <p>Thanks!</p>