Hi, I am trying to escape backslash using regular expression in javascript. See this link please:
link. It does not show backslash in the console but it does in the return value. Is the back slash escaped or do I need to try any other way. Is it possible to escape backslash using regular expression because "replace function " does not seem to make a difference in output.
//Function
function abc(str){
let regex = /\\/g;
//str = str.replace(regex, "");
console.log("str: ", str);
return str;
}
//Tests
let str = "I can\'t do it. I don\'t know.";
abc(str);