title: Can't put index value inside brackets using RegEx
body: <p>There are two strings. I'm trying to put index value inside empty brackets:</p>
  
  <pre><code>var capacity = 'room[price_group_ids][][capacity]';
  var group = 'room[price_group_ids][][group][%s][]';
  </code></pre>
  
  <p>For example, If an index is 1, they should be:</p>
  
  <pre><code>var capacity = 'room[price_group_ids][1][capacity]';
  var group = 'room[price_group_ids][1][group][%s][]';
  </code></pre>
  
  <p>And if the index is 2, they should look like as the following:</p>
  
  <pre><code>var capacity = 'room[price_group_ids][2][capacity]';
  var group = 'room[price_group_ids][2][group][%s][]';
  </code></pre>
  
  <p>What I've tried and it gives unexpected result:</p>
  
  <pre><code>var index = 2;
  
  var capacity = 'room[price_group_ids][][capacity]'.replace(/\[(.+?)\]/g, "[" + index +"]"); // Should become room[price_group_ids][2][capacity]
  var group = 'room[price_group_ids][][group][%s][]'.replace(/\[(.+?)\]/g, "[" + index +"]"); // Should become room[price_group_ids][2][group][%s][]
  </code></pre>
  
  <p>I'm not good at RegEx and looking for an advice on how to resolve that</p>