title: Regular expression parsing a binary file?
body: <p>I have a file which mixes binary data and text data. I want to parse it through a regular expression, but I get this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>TypeError: can't use a string pattern on a bytes-like object
  </code></pre>
  
  <p>I'm guessing that message means that Python doesn't want to parse binary files.
  I'm opening the file with the <code>"rb"</code> flags.</p>
  
  <p>How can I parse binary files with regular expressions in Python?</p>
  
  <p><strong>EDIT:</strong> I'm using Python 3.2.0</p>