title: How to Match Bracket Pairs skipping Escape Ones using Regex
body: <p>I am using Javascipt/Typescript to extract substrings wrapped by curly brackets &quot;{}&quot;. It is guaranteed that there are no nested brackets, but there could be some brackets with escape notation &quot;\{&quot; or &quot;\}&quot;. For these escaped brackets, they are just normal strings.</p>
  <p>Eg.:</p>
  <p>valid:</p>
  <pre><code>{abc} ==&gt; abc
  {a\{bc} ==&gt; a\{bc
  {ab}{c} ==&gt; ab, c
  </code></pre>
  <p>invalid:</p>
  <pre><code>{a{bc}d}
  </code></pre>
  <p>I tried to use something like this: <code>{[^{}]*}</code> to match, and I noticed that <code>lookingbehind</code> might help, but I am not sure how to properly use it in Javascript/typescript, especially in negated set. Could anyone shoot me an example of this?</p>