I have a string that looks like this. It's obviously a multi-line string and I would like to split it into one string per stanza.
{
"timestamp":1317911700,
"application":"system.dev",
"metrics":{
"qlen":0,
"read.bytes":0,
"write.bytes":185165.0123762,
"busy":0.021423
},
"dimensions":{
"device":"sda"
}
}
{
"timestamp":1317911700,
"application":"system.fs",
"metrics":{
"inodes.used":246627,
"inodes.free":28703901,
"capacity.kb":227927024,
"available.kb":209528472,
"used.kb":6820512
},
"dimensions":{
"filesystem":"/"
}
}
{
"status_code":0,
"application":"system",
"status_msg":"Data collected successfully"
}
My regex looks like this:
/^({\n[^}]+^})/m
But I am only capturing:
{
"status_code":0,
"application":"system",
"status_msg":"Data collected successfully"
}
Which kinda makes sense since that's where the first curly brace is. What I am trying to do is capture from anywhere there is a /^{/ to anywhere there is a /^}/ as a single string. But I think the other curly braces in there are tr