var str = "test's t\r and t\n";
str = str.replace(/'/g, "\'");
str = str.replace(/\r/g, "\\r");
str = str.replace(/\n/g,"\\n");
Is it possible to do these 3 replaces in single statement?
I want escape these particular chars. With out escaping it makes some problem. “\n” following chars goes to next line. While passing this as parameter it ll not get it as “\n” in the server.
Try this: