title: how to use regex or split in python2.7
body: <p>this is a file content that has more than 6000 lines of such similar lines:</p>
  
  <pre><code>0000000: 01010000 01001011 00000011 00000100 00010100 00000011  PK....  
  0000006: 00000000 00000000 00001000 00000000 01000000 10001101  ....@.  
  000000c: 00101001 01000110 10011111 00101100 00000001 11100100  )F.,..  
  0000012: 01111100 00101011 00000000 00000000 10111110 11010111  |+....  
  0000018: 00000010 00000000 00001101 00000000 00000000 00000000  ......  
  000001e: 01110000 01100001 01101110 01100100 01100001 01011111  panda_  
  0000024: 01100010 01101001 01101110 00101110 01110100 01111000  bin.tx  
  000002a: 01110100 10101100 10011010 01001001 10101110 10011011  t..I..  
  0000030: 01010000 00010000 01000101 11100111 01011001 10000101  P.E.Y.  
  </code></pre>
  
  <p>and i need is to pull out portion of contents(column 2 to 7 only) from every line till eof and place it inside another file using python.</p>
  
  <p><em>I <strong>first tried</strong> to just copy and paste line after line till eof,.</em>  </p>
  
  <pre><code>import StringIO 
  
  infile = "input.txt"
  outfile = open("dump.txt", "w")
  
  with open(infile, 'r') as contents:
      line_infile = contents.readline()
      while line_infile:
          outfile.write(line_infile)
          line_infile = contents.readline()
  outfile.close()
  </code></pre>
  
  <p><strong><em>It worked.</em></strong> </p>
  
  <p><em>As a second step <strong>i then added 're' inside</strong>.. This is where im unable to do it.
  this is the code i have written:</em></p>
  
  <pre><code>import StringIO 
  import re
  
  infile = "input.txt"
  outfile = open("dump.txt", "w")
  match = re.compile(ur': (.*?)  ')
  
  with open(infile, 'r') as contents:
      line_infile = contents.readline()
      while line_infile:
          outfile.write(re.findall(match, line_infile))
          line_infile = contents.readline()
  outfile.close()
  </code></pre>
  
  <p>which gives error</p>
  
  <pre><code>outfile.write(re.findall(match, line_infile))
  TypeError: expected a character buffer object
  </code></pre>
  
  <p>when tried it with re.copy_reg instead of re.findall </p>
  
  <pre><code>outfile.write(re.copy_reg(match, line_infile))
  TypeError: 'module' object is not callable
  </code></pre>
  
  <p>im a beginner to programming and python. from what i have learnt so far, i have to make use of regex for matching strings, and use buffer to read large amount of datas. im using regular expression <code>': (.*?)  '</code> to select the contents btw 2 matching characters, <code>": "</code>(a ':' and a Space) and <code>"  "</code>('Space' and 'Space' ).  </p>
  
  <p><strong>Question:</strong>  </p>
  
  <ul>
  <li><p>how to copy those contents that matches the regex expression and place
  it inside another file.</p></li>
  <li><p>should i make use of buffer,.(i dont know how to make use of buffer.
  couldn't find much(examples or tutorials) about using buffer with
  readline() and write()module.)</p></li>
  </ul>