<script>
var text = "a's ..a's ...\"... ";
text = convert(text);
function convert( text )
{
var n = text.replace(/\'/g, "'");
n = text.replace(/\"/g,""");
return n;
}
console.log(text);
document.write(text);
</script>
The problem is that when it replace the second time it take doesnt "remember" what it replaced the first time, so only the last replace is returned.