I try to replace "\" character to empty "" but I can't do it. How to solve it?
Here is my code
abc = abc.replace('\','');
I try to replace "\" character to empty "" but I can't do it. How to solve it?
Here is my code
abc = abc.replace('\','');
to replace all occurrences in a string you need to use a regex with the g
flag,
abc = abc.replace(/\\/g, '');
I think you need to escape the backslash:
abc = abc.replace('\\', '');
If you want to replace all occurrences, you can try:
var pattern = '\\\\';
var re = new RegExp(pattern, 'g');
abc = abc.replace(re, '');