title: Regular expression : Match anything but full token
body: <p>I have the following snippet where I would like to extract code between the <code>{foreach}</code> and <code>{/foreach}</code> using a regular expression:</p>
  
  <pre><code>{foreach (...)}
  Some random HTML content &lt;div class=""&gt;aklakdls&lt;/div&gt; and some {$/r/template} markup inside.
  {/foreach}
  </code></pre>
  
  <p>I already have:</p>
  
  <pre><code>{foreach [^}]*}
  </code></pre>
  
  <p>but I am unable to match anything after that. Is there any way to match anything BUT {/foreach} as a whole token? Please note that the content between {foreach}{/foreach} can also contain "{$" tokens.</p>
  
  <p><strong>Edit</strong>: BaileyP's &amp; Tomalak's answers are correct, but I have chosen BaileyP's answer for simplicity sake.</p>