title: python re for opcode parsing
body: <p>I just wrote some code to try and parse opcodes out of an objdump output of the following format :-</p>
  
  <pre><code> 8048060:   89 e7                   mov    edi,esp
   8048062:   89 fe                   mov    esi,edi
   8048064:   6a 6b                   push   0x6b
   8048066:   58                      pop    eax
   8048067:   aa                      stos   BYTE PTR es:[edi],al
   8048068:   6a 65                   push   0x65
   804806a:   58                      pop    eax
   804806b:   aa                      stos   BYTE PTR es:[edi],al
   804806c:   6a 79                   push   0x79
   804806e:   58                      pop    eax
   804806f:   aa                      stos   BYTE PTR es:[edi],al
   8048070:   31 c0                   xor    eax,eax
   8048072:   aa                      stos   BYTE PTR es:[edi],al
   8048073:   40                      inc    eax
   8048074:   cd 80                   int    0x80
  </code></pre>
  
  <p>I wish to extract the opcodes as <code>89 e7 89 f3 .... cd 80</code>.
  I tried using the following regex statement :-</p>
  
  <pre><code>opcode = ""
  for line in f.readlines():
    match = re.search(r' ([\da-f]+):\s+([0-9a-f ]+)', line)
    opcode += match.group(2).strip() + " "
  </code></pre>
  
  <p>Though the above snippet kinda works for all my samples im sure that it would fail in the case where I had an instruction that ended with [a-f][space].</p>
  
  <p>Could someone suggest a better regular expression for the same?</p>