如何在C#或jquery中将双引号替换为单引号?

时间:2018-08-09 05:23:18

标签: c# jquery

我的字符串是<br/>

var lookfor = "\(Dos LIKE ''" + Dos + "'' OR Practice LIKE ''" + PracticeName + "''  OR Patient LIKE ''" + PatientName + "''  OR ClaimId LIKE ''" + ClaimId + "'' OR Charges LIKE ''" + Charges + "'' OR Payment  LIKE ''" + Payment + "'' OR InsuranceStatus  LIKE ''" + Status + "'')";

但是我需要一个字符串<br/>

var lookfor = '\(Dos LIKE ''" + Dos + "'' OR Practice LIKE ''" + PracticeName + "''  OR Patient LIKE ''" + PatientName + "''  OR ClaimId LIKE ''" + ClaimId + "'' OR Charges LIKE ''" + Charges + "'' OR Payment  LIKE ''" + Payment + "'' OR InsuranceStatus  LIKE ''" + Status + "'')';

我正在尝试这段代码,但无法解决

var jsonStr = lookfor.replace(/"/g, "'");
var jsonStr1= lookfor.replace(/"/g, '\'');

请帮助。...

2 个答案:

答案 0 :(得分:0)

var lookfor = "\\(Dos LIKE ''" + Dos + "'' OR Practice LIKE ''" + PracticeName + "''  OR Patient LIKE ''" + PatientName + "''  OR ClaimId LIKE ''" + ClaimId + "'' OR Charges LIKE ''" + Charges + "'' OR Payment  LIKE ''" + Payment + "'' OR InsuranceStatus  LIKE ''" + Status + "'')";
var newTemp = lookfor.Replace("\"", "'");

这里是demo on ideone

答案 1 :(得分:-1)

var jsonStr = lookfor.replace(@“”“”,@“ \”“”);