title: ruby regex match from end of string
body: <p>I've read somewhere today that regex tag in SO gets most "give me ze code" type questions, so I was cautious in asking... I tried, but if this is a duplicate please let me know so I can delete.</p>
  
  <pre><code>[First]sometext[Second]
  </code></pre>
  
  <p>I would like to use Regex in Ruby to return value between second []:</p>
  
  <pre><code>Second
  </code></pre>
  
  <p>I so far have:</p>
  
  <pre><code>(?&lt;=\[)(.*)(?=\])
  </code></pre>
  
  <p>which returns </p>
  
  <p><code>First]sometext[Second</code></p>
  
  <pre><code>\[.*?(\[)
  </code></pre>
  
  <p>this grouping will return </p>
  
  <pre><code>[First]sometext[
  </code></pre>
  
  <p>so I've been struggling to somehow mix the two but no luck.. hope someone can help.</p>
  
  <p>The closest reference I can find in SO was searched with "match second or nth occurence in regex" which I couldn't get it to work on my issue.</p>
  
  <p>my workaround was to use gsub to replace the <code>[First]</code> with "" to the initial string with:</p>
  
  <pre><code>\[(.*?)\]
  </code></pre>
  
  <p>and then do another match.. but I would like know how it can be done with on regex usage.</p>