title: Regex to find out a subtring which is inside curly braces in Java
body: <p>I have this type of subtring </p>
  
  <pre><code>string 1
  {
      string 2
      string 3
      {
          string 4
          string 5
      }
      string 6
      {
          string 7
          string 8
      }
      string 9
      {
          string 10
          string 11
          string 12
          {
              string 13
              string 14
          }
          string 15
      }
  }
  string 16
  string 17
  </code></pre>
  
  <p>so basically i have java class type of structure<br>
  and now i want a piece of code which can get me following substrings(SS#)<br>
  SS1:</p>
  
  <pre><code>        string 4
          string 5
  </code></pre>
  
  <p>SS2:</p>
  
  <pre><code>        string 7
          string 8
  </code></pre>
  
  <p>SS3:</p>
  
  <pre><code>            string 13
              string 14
  </code></pre>
  
  <p>SS4:</p>
  
  <pre><code>string 16
  string 17
  </code></pre>
  
  <p>SS5:</p>
  
  <pre><code>        string 10
          string 11
          string 12
          {
              string 13
              string 14
          }
          string 15
  </code></pre>
  
  <p>SS6:</p>
  
  <pre><code>    string 2
      string 3
      {
          string 4
          string 5
      }
      string 6
      {
          string 7
          string 8
      }
      string 9
      {
          string 10
          string 11
          string 12
          {
              string 13
              string 14
          }
          string 15
      }
  </code></pre>
  
  <p>so basically i want a piece of code that can get me various parts(function, classes, but not any loops) of string(java class) into different substrings...<br>
  i read this<br>
  <a href="https://stackoverflow.com/questions/413071/regex-to-get-string-between-curly-braces-i-want-whats-between-the-curly-brace">Regex to get string between curly braces &quot;{I want what&#39;s between the curly braces}&quot;</a><br>
  but it only gets me data between a pair of '{', and '}' without counting the '{' that have come after the first.<br>
  i don't the full code, but some direction into how to proceed???</p>