title: Extract an alphanumeric string between two special characters
body: <p>I'm trying to match strings in the lines of a file and write the matches minus the first one and the last one </p>
  
  <pre><code>import os, re
  
  infile=open("~/infile", "r")
  out=open("~/out", "w")
  pattern=re.compile("=[A-Z0-9]*&gt;")
  for line in infile:
      out.write( pattern.search(line)[1:-1] + '\n' )
  </code></pre>
  
  <p>Problem is that it says that <code>Match</code> is not subscriptable, when I try to add <code>.group()</code> it says that <code>Nonegroup has no attritube group</code>, <code>groups()</code>   returns that <code>.write</code> needs a tuple etc</p>
  
  <p>Any idea how to get <code>.search</code> to return a string ?</p>