i have a regex challenge i can't solve on my own, i have a json stringified file that hold lots of entries so instead of decoding it and looping over all items i want just use a preg_replace to delete a specific item with specific id.
so my json look like this:
[
{
"id":"440",
"type":"prospect",
"fullname":"elizabeth cogelizabeth",
"phone":"01768413081",
"..." : ""
},
{
"id":"436",
"type":"prospect",
"fullname":"mandy cogmandy",
"phone":"01697349008",
"..." : ""
}
]
what i know is the id part so i can do something like this
preg_replace('/{\"id\"\:\"440\".*?\"},/', '', $jsonBlob);
unfortunately my regex don't keep in count the last item that doesn't end with comma , but with a bracket ]
any help is really appreciated. thanks in advance.
]that should cause",to fail. I think{\s*"id":"440",or{\s*"id":"\d+",is easier to read.preg_replacehere looping through json_decode array is far better{bobby}just to throw off lazy code like this.