如何使用jQuery从字符串中删除特殊字符

如何使用jQuery从字符串中删除特殊字符,jquery,Jquery,我有一根这样的绳子 { "\"test\":\"Connect_Disconnect\",\"os\":\"Windows NT\",\"report\":\"Verify Wireless Interface present and state is Disconnected:OK Verify Profile not present on the Client:OK Add Profile to the Client:OK Verify Profile Added Present o

我有一根这样的绳子

{
    "\"test\":\"Connect_Disconnect\",\"os\":\"Windows NT\",\"report\":\"Verify Wireless Interface present and state is Disconnected:OK
Verify Profile not present on the Client:OK
Add Profile to the Client:OK
Verify Profile Added Present on the Client:OK
Connecting to Access Point:OK
Verify the State is Connected:OK
Disconnecting from Access Point:OK
Verify the State is Disconnected:OK
Delete Profile to the Client:OK
Verify Profile Not Present on the Client:OK
\"": ""
}
如何使用jQuery删除特殊字符并获得如下所示的输出:

test:Connect_Disconnect,os:Windows NT,report:Verify Wireless Interface present and state is Disconnected:OK
Verify Profile not present on the Client:OK
Add Profile to the Client:OK
Verify Profile Added Present on the Client:OK
Connecting to Access Point:OK
Verify the State is Connected:OK
Disconnecting from Access Point:OK
Verify the State is Disconnected:OK
Delete Profile to the Client:OK
Verify Profile Not Present on the Client:OK
试试这个

var product= $("#product").val().replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, ' ')

请尝试在javascript中替换函数

  var val='"\"test\":\"Connect_Disconnect\",\"os\":\"Windows NT\",\"report\":\"Verify Wireless Interface present and state is Disconnected:OK Verify Profile not present on the Client:OK Add Profile to the Client:OK Verify Profile Added Present on the Client:OK Connecting to Access Point:OK Verify the State is Connected:OK Disconnecting from Access Point:OK Verify the State is Disconnected:OK Delete Profile to the Client:OK Verify Profile Not Present on the Client:OK \"": ""';

        val=val.replace(/"/g,'');
        val=val.replace(/\\/g,'');

明确地说,您希望删除哪些精确字符?您是指JSON字符串吗?这不是有效的JSON。我认为提问者希望删除“\”字符,我只想删除“”和/charecters@Sush您的实际输出是什么?我只想删除“”和/字符它是我尝试您的代码
{test\\:\\Connect\u Disconnect\\,\\os\\:\\Windows NT\\,\\report\\:\\Verify无线接口存在且状态已断开:确定验证配置文件不存在于客户端:确定将配置文件添加到客户端:确定验证配置文件添加到客户端:确定连接到接入点:确定验证状态已连接:确定从接入点断开:确定版本通知状态已断开:确定删除客户端配置文件:确定验证客户端上不存在配置文件:确定\\:}“