i have following code for replacing
var temp = \"^hall^,^restaurant^\"; temp.replace(/^/g, \'\'); console.log(temp);
This does not Replace
temp = temp.replace(/\^/g, '');
It is replacing once you escape the caret.
https://jsfiddle.net/ym7tt1L8/
And note that just writing temp.replace(/\^/g, ''); doesn't update your actual string. That is the reason you have to write
temp.replace(/\^/g, '');