有個(gè)需求,在向后臺(tái)提交數(shù)據(jù)時(shí),將"字符轉(zhuǎn)義后再提交。前臺(tái)的數(shù)據(jù)既有對(duì)象格式(或數(shù)組),也有JSON格式,我會(huì)在ajax請(qǐng)求前,將數(shù)據(jù)統(tǒng)一轉(zhuǎn)為JSON格式,這個(gè)時(shí)候,如果輸入有",那么,會(huì)被轉(zhuǎn)為",數(shù)據(jù)格式如下:"{"houseTypeName":"\"good","coveredArea":"4567","tablePrice":"4567","buildingId":"9"}"希望通過正則表達(dá)式,改為:"{"houseTypeName":""good","coveredArea":"4567","tablePrice":"4567","buildingId":"9"}"但是,我實(shí)驗(yàn)了/\"/g或者/"/g,都不行,會(huì)把所有"轉(zhuǎn)義,這樣肯定是不對(duì)的。求正則大神支招,萬分感謝!
ajax提交數(shù)據(jù)時(shí),如何用正則表達(dá)式替換掉"號(hào)?
慕桂英4014372
2018-08-28 09:27:52