I have a string that looks like below, and I have to remove everything between the first bracket and the last bracket. All bets are off, on what’s in between (regarding other brackets). What would be the best aproach, thanks.
'[
{ "foo":
{"bar":"foo",
"bar": {
["foo":"bar", "foo":"bar"]
}
}
}
],
"foo":"bar","foo":"bar"'
result:
',
"foo":"bar","foo":"bar"'
If your data really does look like that and you don’t have an brackets in the bit at the end then:
If you want to be a little more paranoid, then you can look for
],followed by an end-of-line:Hard to say any more than that without a specification of your data format.