Hello,
I want to write a script which adds in a string a backslash () everytime it finds a quotation marks or \r. It works but for " and ', but I don't know how to write it for \r. Could anyone help me? THANKS
<script type="text/javascript">
var test="Let\'s test if this \"works\" properly";
var escapedString = test.replace(/(['"])/g, "\\$1");
document.write(escapedString);
</script>
Output: Let\'s test if this \"works\" properly