title: Regex/token/rule to match nested curly braces?
body: <p>I need to match the values of <code>key = value</code> pairs in BibTeX files, which can contain arbitrarily nested braces, delimited by braces. I've got as far as matching at most two deep nested curly braces, like <code>{some {stuff} like {this}}</code> with the kludgey:</p>
  <pre><code>    token brace-value {
      '{' &lt;-[{}]&gt;* ['{' &lt;-[}]&gt;* '}' &lt;-[{}]&gt;* ]* '}'
      }
  </code></pre>
  <p>I shudder at the idea of going one level further down... but proper parsing of my BibTeX stuff needs at least three levels deep.</p>
  <p>Yes, I know there are BibTeX parsers around, but I need to grab the complete entry for further processing, and peek at a few keys meanwhile. My <code>*.bib</code> files are rather tame (and I wouldn't mind to handle a few stray entries by hand), the problem is that I have a lot of them, with much overlap. But some of the &quot;same&quot; entries have different keys, or extra data. I want to consolidate them into a few master files (the whole idea behind BibTeX, right?). Not fun by hand if <code>bibtool</code> gives a file with no duplicates (ha!) of some 20 thousand lines...</p>