title: How to match beginning of string or character in Python
body: <p>I have a string consisting of parameter number _ parameter number:</p>
  
  <pre><code>dir = 'a1.8000_b1.0000_cc1.3000_al0.209_be0.209_c1.344_e0.999'
  </code></pre>
  
  <p>I need to get the number behind a parameter chosen, i.e.</p>
  
  <ul>
  <li><code>par='be'</code> -->need 0.209</li>
  <li><code>par='e'</code> -->need 0.999</li>
  </ul>
  
  <p>I tried:</p>
  
  <pre><code>num1 = float(re.findall(par + '(\d+\.\d*)', dir)[0])
  </code></pre>
  
  <p>but for <code>par='e'</code> this will match <code>0.209</code> <em>and</em> <code>0.999</code>, so I tried to match the parameter together with the beginning of the string or an underscore:</p>
  
  <pre><code>num1 = float(re.findall('[^_]'+par+'(\d+\.\d*)', dir)[0])
  </code></pre>
  
  <p>which didn't work for some reason.</p>
  
  <p>Any suggestions? Thank you!</p>