I am trying to parse information with regex, that is laid out in a style similar to json. Part of the problem I am having doing this involved identifying pairs of curly brackets.
group = {
field = element
innergroup = {
field = element
field = element
}
field = element
innergroup = { field = element }
}
array = { field = element }
The first step in solving this problem is to identify the inner groups, bracketed off material that has no curly brackets between them. In the above example:
innergroup = {
field = element
field = element
}
#and
innergroup = { field = element }
#and
array = { field = element }
I have tried to find these inner groups by using a few different regex commands. This is the closest I got.
\{.*?\}
I know that it has something to do with the fact that the "." character means all characters except for line breaks. I also have to figure out a way to rule out characters that are either of the curly brackets.
[Update]
Previous questions have asked how to do this when the curly brackets are all on one line. However, this does not address this innergroup.
innergroup = {
field = element
field = element
}
The other questions also don't take into account the fact that there are many curly brackets, and thus other regex functions will find things like.
group = {
field = element
innergroup = {
field = element
field = element
}
Any help is appreciated. Thanks.