How to split escape character in this string?
already tried doing this
str = str.split('\\');
console.log(str);
this is the output
I want an output something like this
please help. thank you.
How to split escape character in this string?
already tried doing this
str = str.split('\\');
console.log(str);
this is the output
I want an output something like this
please help. thank you.
The escape character is consumed when the string literal is parsed so there are no \
characters in the string to replace.
It is too late to fix this programmatically. You need to edit the original source code to represent \
characters as \\
.
You can't create a string like this, you have to use the double backslash.
var str = "..\..\common\core\services\shared.service";
console.log(str); // "....commoncoreservicesshared.service"
// Correct way
var str = "..\\..\\common\\core\\services\\shared.service";
console.log(str); // "..\..\common\core\services\shared.service"
// Then use this:
str.replace(/\\/g, '/');