title: Regex - moving matched text to earlier in line
body: <p>I have been using regex (in textmate's find &amp; replace tool) to reformat a table of values I've received into a PHP array.</p>
  
  <p>I've got most of the way there - but struggling with the final change.</p>
  
  <p>The current status:</p>
  
  <pre><code>$subSectors[1] = 'Crop &amp; Animal Production, Hunting &amp; Related Service Activities'; [1]
  $subSectors[2] = 'Forestry &amp; Logging'; [1]
  </code></pre>
  
  <p>I'm looking to batch replace (100s of lines) so that the final characters [\d{0-3}] move to be the main array key.</p>
  
  <p>So the above two lines would become:</p>
  
  <pre><code>$subSectors[1][1] = 'Crop &amp; Animal Production, Hunting &amp; Related Service Activities';
  $subSectors[1][2] = 'Forestry &amp; Logging';
  </code></pre>
  
  <p>The end of line bracketed values can be 1-3 digits in length. </p>
  
  <p>I can match the bracketed values using: </p>
  
  <pre><code>\[\d{0,3}]$
  </code></pre>
  
  <p>But at a loss of how to structure the replacement string. </p>