title: RegEx - Value inside double square brackets
body: <p>I'm trying to extract a value inside Double Square brackets: <code>[[x]]</code>, whilst ignoring everything else in single square brackets: <code>[y]</code>. </p>
  
  <p><strong><em>NOTE:</strong> This RegEx is to be used in JavaScript, which as far as I understand doesn't support Looking behind</em></p>
  
  <p>For example, take these 3 strings</p>
  
  <pre><code>[[32]] [Test] Lorem Ipsum
  [[16]] Lorem Ipsum
  [[2]] Test [BUG]
  </code></pre>
  
  <p>I want to extract: <strong>32, 16, 2</strong></p>
  
  <p>This is what I've tried</p>
  
  <p><strong>Test 1:</strong></p>
  
  <p><code>\[([0-9]+)\]</code></p>
  
  <p><a href="http://www.regexr.com/39sm3" rel="nofollow">http://www.regexr.com/39sm3</a></p>
  
  <p>Will only return the value including the inner square brackets, e.g. <strong>[32], [16], [2]</strong>. I could then just do another RegEx on the result, but I'd like to know how to do it once.</p>
  
  <p><strong>Test 2:</strong></p>
  
  <p><code>\[.*?\]]</code></p>
  
  <p><a href="http://www.regexr.com/39sm0" rel="nofollow">http://www.regexr.com/39sm0</a></p>
  
  <p>Will return the value, with the double square brackets, e.g. <strong>[[32]], [[16]], [[2]]</strong></p>