Javascript 需要从按键搜索的值中删除两个引号
我试图使用regex键删除json值中出现的引号,数据本身有引号,在json中也有引号,在其中它在json中抛出错误意外标记sJavascript 需要从按键搜索的值中删除两个引号,javascript,regex,Javascript,Regex,我试图使用regex键删除json值中出现的引号,数据本身有引号,在json中也有引号,在其中它在json中抛出错误意外标记s "{"segerity": 5,"someData": ""AB3EncKrodPvc"", "segerity": 2}" 我正在这样努力 const quoteRemove = quoteReplace.replace(/someData["]+/g, ''); 预期结果 "{"segerity": 5,"someData": "AB3EncKrodPvc",
"{"segerity": 5,"someData": ""AB3EncKrodPvc"", "segerity": 2}"
我正在这样努力
const quoteRemove = quoteReplace.replace(/someData["]+/g, '');
预期结果
"{"segerity": 5,"someData": "AB3EncKrodPvc", "segerity": 2}"
您可以使用将两个或多个连续的
“
替换为单个”
let str=`{“segerity”:5,“someData”:“AB3EncKrodPvc”,“segerity”:2}`
设op=str.replace(/“{2,}/g,”)
console.log('string-->',op)
console.log('Object-->',JSON.parse(op))
@MaheerAli谢谢,+
表示一个或多个,并将“
再次替换为”
,这是有意义的
/"{2,}/