I have a variable with this kind of string: 4.5"x8.5"x0.5"
I found many answers about how to escape the quotes, so I write this function:
function replaceQuotesChars (str)
{
var s = str.trim();
// s.replace('"','"');
// s.replace('"','\\"');
// s.replace(/\"/g,'\\"');
s.replace(/\"/g,'"');
return s;
};
But none of those help me to escape the quotes because I get the same string that I submit to the function.
I save that variable with a stringify object to the database so when I parse back the string I get an error.
What I'm doing wrong? Please help me.