为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

C#
holdtom 2021-11-21 14:41:21
我的字符串是 <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 回答

?
叮当猫咪

TA贡献1776条经验 获得超12个赞

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("\"", "'");

这是ideone 上演示


查看完整回答
反对 回复 2021-11-21
?
蛊毒传说

TA贡献1895条经验 获得超3个赞

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


查看完整回答
反对 回复 2021-11-21
  • 2 回答
  • 0 关注
  • 168 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信