title: Regex (regular expressions), replace the second occurence in javascript
body: <p>This is an example of the string that's being worked with:</p>
  
  <pre><code>xxxxxx[xxxxxx][7][xxxxxx][9][xxxxxx]
  </code></pre>
  
  <p>I'm having a little trouble matching the second occurrence of a match, I want to return the 2nd square brackets with a number inside. I have some regex finding the first square backets with numbers in a string:</p>
  
  <pre><code>\[+[0-9]+\]
  </code></pre>
  
  <p>This returns [7], however I want to return [9].</p>
  
  <p>I'm using Javascript's replace function, the following regex matches the second occurrence (the [9]) in regex testeing apps, however it isn't replaced correctly in the Javascript replace function:</p>
  
  <pre><code>(?:.*?(\[+[0-9]+\])){2}
  </code></pre>
  
  <p>My question is how do I use the above regex to replace the [9] in Javasctipt or is there another regex that matches the second occurrence of a number in square brackets.</p>
  
  <p>Cheers!</p>