📅  最后修改于: 2022-03-11 15:01:38.931000             🧑  作者: Mango
const regex = /}}/ig
const commaEndOfObjects = response.data.replace(regex, '}},');
const lastCommaToRemove = commaEndOfObjects.lastIndexOf('}},') + 2
const removeLastComma = commaEndOfObjects.slice(0, lastCommaToRemove) + commaEndOfObjects.slice(lastCommaToRemove +1);
const onlySingleQuotes = removeLastComma.replace(/'/g, '"');
const insideArray = `[${onlySingleQuotes}]`
const result = JSON.parse(insideArray)