I\'m trying to replace the \"\'\" character with the \"\'\'\" string using the replace method, like this:
temp.replace(\"\\\'\", \"\'\'\");
but
Your code just replaces a single instance (the first one it finds). You should replace all instances. You can do this by using a regular expression and adding a g
flag to the end meaning "global search". Like this:
temp.replace(/'/g, "''")
Here's a working example: http://jsfiddle.net/Q2Uyv/ (type something into the "In" box and click "Convert").
If you are actually trying to replace single quotes with double quotes (instead of doubled sequence of single quotes), do this:
temp.replace(/'/g, '"')