How to match the last occurrence of a pattern using regex
<p>I have a string like</p>

<pre><code>{{token1}}/{{token2}}
</code></pre>

<p>I want to match <code>{{token2}}</code> using regex.</p>

<p>other possible cases that it should match are</p>

<p><code>{{token1}}/{</code> should match <code>{</code> (the last one).</p>

<p><code>{{token1}}/{{</code> should match <code>{{</code> (the last one).</p>

<p><code>{{token1}}/{{token2</code> should match <code>{{token2</code>.</p>

<p>I tried <code>/\S+$/</code> but it works when the string is <code>{{token1}} {{token2}}</code>.</p>

<p>Thanks in advance.</p>