how to remove \ (backslash ) symbol from string using javascript
var str ='Visit\ Microsoft \';
var res = str.replace(/\//g, "-");
alert(res);
it should be
var str = 'Visit\\ Microsoft \\';
var res = str.replace(/\\/g, "-");
alert(res);
you need to escape the \ with another \ as back slash is a escape character, also the regex should be /\\/g
Demo: Fiddle
Have you noticed the color change in your HTML Code?
var str ='Visit\ Microsoft \';
var res = str.replace(/\//g, "-");
alert(res);
Everything after Microsoft is red, that indicates everything after Microsoft is also a string.
\ Backslash works as a except character, So it except closing "'" mark.
Please check your code, you may need to add backslash before Space, like below
var str ='Visit\ Microsoft\ ';
var res = str.replace(/\//g, "-");
alert(res);
This Code will work as you wanted.
/\\/gto find them.