All-
I love regex quite a bit, but when there are multiple types of parsing I get quite confused.
I’m basically trying to parse data such as this:
{"classs":15,"commondrop":true,"id":7101,"level":1,"name":"7Z",
"slot":0,"source":[2],"subclass":0,
modes: { "mode":4,
"4": { "count":15862,"outof":36461 }
},
count:15862, stack:[1,1]
},
{"classs":15,"commondrop":true,"id":62530,"level":1,"name":"7Z",
"slot":0,"source":[2],"subclass":0,
modes:{ "mode":4,
"4":{ "count":13402,"outof":36461 }
},
count:13402,stack:[1,1]
},
{"classs":15,"commondrop":true,"id":3300,"level":5,"name":"7Rabbit's Foot",
"slot":0,"source":[2],"subclass":0,
modes:{"mode":4,
"4":{ "count":1,"outof":36461 }
},
count:1,stack:[1,1]
}
]});
Since there are sub brackets (the { and }) I’m not entirely sure how to ONLY get what is in the outter bracket. So I would just want to get this out of it:
"classs":15,"commondrop":true,"id":7101,"level":1,"name":"7Z","slot":0,"source":[2],"subclass":0,modes:{"mode":4,"4":{"count":15862,"outof":36461}},count:15862,stack:[1,1]
(which I could then parse further and break it down more)
Is this even possible with regex? I started off trying something like \{"classs"(.*?)\},{ but it misses some of the data.
counting brackets is not possible with regular expressions, because these aren’t regular languages. The solution will be to use i.e. a Parsing Expression Grammar implementation instead of a RegEx.