js Replacing Single Quotation Mark with Double Quotation Mark and Replacing Double Quotation Mark with Single Quotation Mark
- 2021-07-21 07:17:24
- OfStack
1. Replace double quotation marks with single quotation marks
var _adrobj = JSON.stringify(address).replace(/\"/g,"'");ps:
var a = {a:1,b:2};
JSON.stringify(a)====>"{"a":1,"b":2}"
2. Replace single quotation marks with double quotation marks
var _nstr = _adrdata.replace(/'/g, '"');ps:
var json = JSON.parse(_nstr);
if (json.storeDelivery == 0) {
msgBox($.msg.OutDistributeAddress);
return;
}
function escapeHTML(a) {
return a.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/ /g, " ").replace(/"/g, """).replace(/'/g, "'")
}