title: Hex pattern parsing in Python code (using Bitstring)
body: <p>I'm prototyping a specific file editor and am having trouble parsing my hex files and finding a specific pattern. Here is my code (using the <a href="http://code.google.com/p/python-bitstring/" rel="nofollow">Bitstring</a> library):</p>
  
  <pre><code>from bitstring import BitArray, BitStream, Bit
  f = open('d:\BB.bin', "rb")
  s = BitArray(f)
  f1 = s.find('0x000015354444444343434344444444434343434444444400F700F0')
  
  &gt;&gt;&gt; print(f1)
  (15232,)
  </code></pre>
  
  <p>This part is OK -- but I wonder what the output <code>15232</code> refers to? (In my file, the actual pattern is located at <code>770h</code>).</p>
  
  <p>My main problem is looking for this kind of pattern but only with the 3 first bytes (<code>0x000015</code>) and the last ones (<code>0xf700f0</code>): I'm interested in getting the middle part only.</p>
  
  <p>I've tried different solutions, but with no luck, any ideas?</p>
  
  <pre><code>f1 = s.find('0x000001''(.*)''F700F0')  
  f1 = s.find('0x000001''0x.''0xF700F0') 
  </code></pre>