I am a newbie when it comes to regex. I have a json string that includes timestamp, I would like to remove all the occurrences of the date
field in the string.
the beautified json string looks like this:
{
"abc": 157,
"efg": 1,
"hij": "1",
"klm": "0.00",
"created_at": {
"date": "2020-04-08 12:53:34.682759",
"timezone_type": 3,
"timezone": "UTC"
},
"updated_at": {
"date": "2020-04-08 12:53:34.682759",
"timezone_type": 3,
"timezone": "UTC"
}
}
I want to remove the all the occurrences of the string that starts with "date": "
and ends with ",
so the output would look like the following:
{
"abc": 157,
"efg": 1,
"hij": "1",
"klm": "0.00",
"created_at": {
"timezone_type": 3,
"timezone": "UTC"
},
"updated_at": {
"timezone_type": 3,
"timezone": "UTC"
}
}
I know preg_match_all
can actually help find all matching occurrences, however, i found difficulties in building the pattern especially that my pattern includes commas and double quotes.