I have a JSON file that I want to use PHP to replace the "Systems_x0020_Changed_IDs" value from a string to an array. "39122" becomes [39122] and "39223, 39244, 39395" becomes [39223, 39244, 39395]. I am using http://www.regexpal.com/ to test my expression. The expression is:
"([(0-9)+((, *))]+)+"
This is producing unexpected results in PHP. In my JSON file:
[{
"ID": 1050436,
"Title": "THE SKY IS FALLING!!!!",
"Application_x0020_ID": 242,
"Systems_x0020_Changed": "Academic Planning System (APS),\"Documents planning and evaluation processes at UGA that support cont",
"Systems_x0020_Changed_IDs": "39122",
"Status": "New",
"Modified": "2015-10-28T16:14:45.573-04:00",
"Age": 40,
"Description_x0020__x0028_Public_x0029_": "I'm chicken little and the SKY IS FALLING!",
"Impact_x0020__x0028_Public_x0029_": "The world is going to end!",
"Start_x0020_Time": "2015-10-28T00:00:00-04:00",
"End_x0020_Time": "2015-10-30T00:00:00-04:00",
"Hours": 12
}, {
"ID": 1050740,
"Title": "This is a Title",
"Application_x0020_ID": 242,
"Systems_x0020_Changed": "EITS Websites,\"EITS departmental web pages.\", GACRC Archival Storage,\"Archival Storage for Research Data\", VPS,\"Mainframe distributed printing system\"",
"Systems_x0020_Changed_IDs": "39223, 39244, 39395",
"Status": "New",
"Modified": "2015-11-05T17:31:13.15-05:00",
"Age": 32,
"Description_x0020__x0028_Public_x0029_": "We will tell jokes to the clients",
"Impact_x0020__x0028_Public_x0029_": "Everyone will notice the change.",
"Start_x0020_Time": "2015-11-27T08:38:00-05:00",
"End_x0020_Time": "2015-11-30T00:00:00-05:00",
"Hours": 1
}]
Several commas at the end of lines are being replaced with brackets[] so that the output looks like:
[{
"ID": 1050436,
"Title": "THE SKY IS FALLING!!!![,]Application_x0020_ID": 242,
"Systems_x0020_Changed": "Academic Planning System (APS),\"Documents planning and evaluation processes at UGA that support cont[,]Systems_x0020_Changed_IDs": 39122,
"Status": "New[,]Modified": "2015-10-28T16:14:45.573-04:00[,]Age": 40,
"Description_x0020__x0028_Public_x0029_": "I'm chicken little and the SKY IS FALLING![,]Impact_x0020__x0028_Public_x0029_": "The world is going to end![,]Start_x0020_Time": "2015-10-28T00:00:00-04:00[,]End_x0020_Time": "2015-10-30T00:00:00-04:00[,]Hours": 12
}, {
"ID": 1050740,
"Title": "This is a Title[,]Application_x0020_ID": 242,
"Systems_x0020_Changed": "EITS Websites,\"EITS departmental web pages.\", GACRC Archival Storage,\"Archival Storage for Research Data\", VPS,\"Mainframe distributed printing system\"[,]Systems_x0020_Changed_IDs": [39223, 39244, 39395],
"Status": "New[,]Modified": "2015-11-05T17:31:13.15-05:00[,]Age": 32,
"Description_x0020__x0028_Public_x0029_": "We will tell jokes to the clients[,]Impact_x0020__x0028_Public_x0029_": "Everyone will notice the change.[,]Start_x0020_Time": "2015-11-27T08:38:00-05:00[,]End_x0020_Time": "2015-11-30T00:00:00-05:00[,]Hours": 1
}]
My question is, how can I modify the expression so that PHP will behave like regexpal.com and only get the numbers within quotes and ignore the rest?
json_decode, modifying the structure, and writing it back out withjson_encode.