/* * @Description: 替换对象的key值 * @Autor: kindring * @Date: 2021-12-20 14:17:42 * @LastEditors: kindring * @LastEditTime: 2021-12-20 14:32:21 * @LastDescript: */ let testdata = { a: '5s5', b: 345 } let json = JSON.stringify(testdata); console.log(json); let keyReg = new RegExp(`\"a\"\:\"|\d`) let c2 = json.replace(keyReg, `"${'ffff'}":`) console.log(c2);