title: Javascript Regular Expression get contents between curly brackets (with curly brackets inside)
body: <p>Think of a string like this:</p>
  
  <pre><code>public function test(data)
  {
      if (1 == 2)
      {
          alert("Wtf?");
      }
  
      switch (data)
      {
          case 'test':
              alert("Test");
          break;
      }
  }
  </code></pre>
  
  <p>I need to parse that string, so that I have the body (content) of that function.</p>
  
  <p>I already got my reg exp working so that I have the contents of the function, but when there is an ending }. The regular expression stops and the content will look like this:</p>
  
  <pre><code>if (1 == 2)
  {
     alert("Wtf?");
  </code></pre>
  
  <p>I really hope somebody can help me out..</p>
  
  <p>this is my Reg Exp for splitting this string:</p>
  
  <pre><code>var test = classContent.replace(/(?:(private|public)\s*)function\s*([a-zA-Z0-9_]+)\s*\(([a-zA-Z0-9_\,\s]*)\s*\)\s*{([^}]+)\}/gi, function(a, b, c, d, e) {
  
      classMethods[c] = {
          visibility : b.trim(),
          params : d.trim(),
          content : e.trim()
      };
  });
  </code></pre>