title: capture with regex in javascript
body: <p>I have a string like "ListUI_col_order[01234567][5]". I'd like to capture the two numeric sequences from the string. The last part between the square brackets may contain 2 digits, while the first numeric sequence always contains 8 digits (And the numbers are dynamically changing of course.) Im doing this in javascript and the code for the first part is simple: I get the only 8digit sequence from the string:</p>
  
  <pre><code>var str = $(this).attr('id');
  var unique = str.match(/([0-9]){8}/g);
  </code></pre>
  
  <p>Getting the second part is a bit complicated to me. I cannot simply use:</p>
  
  <pre><code>var column = str.match(/[0-9]{1,2}/g)
  </code></pre>
  
  <p>Because this will match '01', '23', '45', '67', '5' in our example, It's clear. Although I'm able to get the information what I need as column[4], because the first part always contains 8 digits, but I'd like a nicer way to retrieve the last number.
  So I define the contex and I can tell the regex that Im looking for a 1 or 2 digit number which has square brackets directly before and after it:</p>
  
  <pre><code>var column = str.match(/\[[0-9]{1,2}\]/g)
  // this will return [5]. which is nearly what I want
  </code></pre>
  
  <p>So to get Only the numeric data I use parenthesis to capture only the numbers like:</p>
  
  <pre><code> var column = str.match(/\[([0-9]){1,2}\]/g)
   // this will result in:
   // column[0] = '[5]'
   // column[1] = [5]
  </code></pre>
  
  <p>So my question is how to match the '[5]' but only capture the '5'? I have only the [0-9] between the parenthesis, but this will still capture the square brackets as well</p>