title: grep and valid parenthesis sequence
body: <p>I need to extract all indices from my latex files. But some indices may look like this</p>
  
  <blockquote>
    <p>\index{*3*sqrt*uppersqrt{\hspace{-2.5pt}$\uppersqrt{\;\;\;}$(upper
    square root)}}</p>
  </blockquote>
  
  <p>So i need to somehow count in regex number of currently opened curly brackets. I don't know how to handle such a case.</p>
  
  <p>Also, if index contain <code>/</code> then i don't need such index.</p>
  
  <p>Example:</p>
  
  <pre><code>Anything before. \index{{}{}}\index{Hi}\anothertag{something}
  \index{}{}
  \index{/}
  </code></pre>
  
  <p>expected result is</p>
  
  <pre><code>\index{{}{}}
  \index{Hi}
  \index{}
  </code></pre>