I want to replace backslash => '\' with secure \ replacement.
But my code replacing all '#' fails when applied for replacing '\':
el = el.replace(/\#/g, '#'); // replaces all '#' //that's cool
el = el.replace(/\\/g, '\'); // replaces all '\' //that's failing
Why?
elcontains'\'characters?#doesn't need to be escaped;el.replace(/#/g, '#')should work. And also your code to replace backslashes works fine here.