I would like to use a regex expression in Python that matches something like r'{.*?}', or in plain English curly braces along with everything inside them. (I am only concerned with the outermost and would like to ignore inner curly braces)
The problem with this expression is that with nested curly braces you don't get everything because you stop at the first closing brace even if it is not the matching one.
Note r'{.*}' is not a solution because there are more than one group of matching outer curly braces in the text that is being parsed.
For example if the text was:
struct my_struct{
double d;
struct {int i;, char c;} s;
};
I would want the expression to match:
{
double d;
struct{int i; char c;} s;
}
Any pointers on how to account for nested curly braces would be appreciated. Note that I am looking for one where whitespace does not hold any meaning. Solutions that say don't use regex, don't use Python, or go about it in a different way are not useful as this is part of a larger regex expression.