How to replace all \" to " in a string?
I tried, but it doesn't works: var foobar = ("foo\\\"bar\\\"foo").replace(/"\\\""/,'"');
The result is foo\"bar\"foo , but it should be foo"bar"foo
Try .replace(/\\"/g,'"'); - regexes don't need quotes around them, I'm surprised you get any result at all.
You need to fix your regex, you need to do
replace(/\\\"/g, "\"")
Try defining it like this
var foobar = ("foo\\\"bar\\\"foo").replace(/"\\\""/g,'"');
note that the .replace has a /g which makes it global
// initial string
var str = "AAAbbbAAAccc";
// replace here
str = str.replace(/A/g, "Z");
alert(str);
replace...str.replace() it doesn't, in fact, help in any way to the OP.