问题描述:

Im trying to get rid of all quotations in a string.

example string

["value 1", "value 2", "value 3" ,"value 4"]

*this is what I tried, and it worked on one of the Regex online testers. Probably not JQuery though.

string = string.replace(new RegExp(/[^a-zA-Z ,]/g,""));

网友答案:

Try this, it will remove all "s from your string:

var x = '["value 1", "value 2", "value 3" ,"value 4"]';

newString  = x.replace(/"/g, "");
网友答案:

Just replace the quotes only:

string = string.replace(new RegExp('"','g'),'');
网友答案:

If the string is

 var string = '["value 1", "value 2", "value 3" ,"value 4"]';

Then you can remove the quotes using:

string = string.replace(/[^a-zA-Z0-9 ,\[\]]/g,"");
相关阅读:
Top