全部-
我非常喜欢正则表达式,但是当有多种类型的解析时,我会感到很困惑。
我基本上是在尝试解析这样的数据:
{"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]
}
]});
由于有子括号({ 和}),我不完全确定如何只获取外括号中的内容。所以我只想摆脱它:
"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"(.*?)\},{
但它错过了一些数据。