title: Python regex or split/strip to get int from between brackets in line of text
body: <p>I have a text file with lines like this:</p>
  
  <pre><code>[00451] Kayle - 2/3/15 - Win - 2012-11-22
  </code></pre>
  
  <p>the number between the brackets [   ] at the start is an id number, I need to get that from the last line of the file (or a string passed containing that line) so I can increment it for writing more lines to the file so every game record will have a unique id number. I've been trying for a while with split, strip, and regex, but I can't seem to get it to work. Can anyone help? I could just use lines of the file to do this maybe but I wanted to be able to re-sort the file later on by id, name, or other criteria.</p>
  
  <p>My data written to the file in my other code looks like this:</p>
  
  <pre><code>data = "[%s] %s - %s/%s/%s - %s - %s\n" % (id, champname, kills, deaths, assists, winloss, timestamp)
  </code></pre>
  
  <p>How can I get the id of the last line so I can increment future appends id?</p>