I've been trying to extract any text between two curly braces, but the thing is that this text can possibly contains others curly braces.
The regex I've been trying (see below) does not work as it does not stop to the ending curly brace.
Actual regex
/class\s+([A-Z]{1}[a-zA-Z0-9]+)\s+(?:<\s+([a-zA-Z0-9]+))?\s*{(.|\n|\r)*}/gm
And according to the sample below, it matches the rest of the text for the third group
Sample
class Main < Console {
+ main:Int () {
!String hello = "Hello, World!";
this.out(hello);
>> 0;
}
}
class Foobar {
+ foobar:None () {
#Some code...
}
}
Matches
Group 1: Main
Group 2: Console
Group 3:
Does anyone has an idea of how to achieve this (if it's even possible with only Regex)?