Q:

javascript replace instance of string

I want to replace all instance of particular string using javascript/jquery.
My source string is '\\n' and my desired output is '\n'.
this should happen at all instance with in a string.

A:

var str = "hii All, \\n I am sambo. \\n Thank you for listening.";
var res = str.replace(/\\n/gi, "\n");
console.log(str);

Use replace with regex.

