title: Extracting part of a string with regex
body: <p>I am trying to extract two characters from the middle of a string. From the strings <code>['data_EL27.dat', 'data.BV256.dat', 'data_BV257.dat']</code>, I wish to output <code>['EL', 'BV', 'BV']</code>.</p>
  
  <p>Here's what I have using regex, this seems overly clunky for such a simple task, I feel like I'm missing some nicer way of doing this.</p>
  
  <pre><code>import re
  
  str = 'data_EL27.dat'
  m = re.search(r'(?:data[._])(\w{2})', str)
  m.group(1) # 'EL'
  </code></pre>
  
  <p>I realise that in this case I can just take <code>str[5:7]</code> but I don't want to rely on the length of the prefix remaining the same.</p>