title: Ignore ending character if a other character was found (find the scope in code)
body: <p>I'm currently trying how to use Regex in C++ for more advanced stuff like creating my own coding language (just for the fun of it) and I'm having a bit of a problem with reading out the scope of the code.</p>
  
  <p>I'm currently using this text to test my Regex against,</p>
  
  <pre><code>private char test;
  public static int foo = 0;
  private int var = 0;
  private void run(char data, int add) 
  {
       var += 50 + add;
       print (var + test, asdm, asf.getString());
       if (var == 70) {
          print("yes");
       }
  }
  </code></pre>
  
  <p>And the regex I'm using to read out the scope of run and the if-statement within it is,</p>
  
  <pre><code>\{([\S\s]*?)\}
  </code></pre>
  
  <p>This is what it matches atm</p>
  
  <pre><code>{
      var += 50 + add;
      print (var + test, asdm, asf.getString());
      if (var == 70) {
          print("yes");
      }
  </code></pre>
  
  <p>The problem is that it find a } before the actual } it needs, I'd like to know if there is a way to go around this and capture each individual scope as it's own part.</p>
  
  <p>I've tried messing around with loopbacks but I keep getting the error 'The expression contained mismatched ( and )' even though it should be valid regex. Edit, I found out that the c++ version of regex (default one) does not support lookbehind which is why it didn't work.</p>