Remove all backslashes in Javascript

How to remove all backslash in a JavaScript string?

var str = "one thing\\\ for certain: power blackouts and surges can damage your equipment.";

I want a conclusion like

one thing for certain: power blackouts and surges can damage your equipment.

Update:

I delete the data from the page using JavaScript and show it in a popup.

Please help me with this.

+6
source share
4 answers

Use a simple regex to solve it

str = str.replace(/\\/g, '')

Demo: Fiddle

+30
source

This is the answer according to the heading, as the heading is " Delete all slashes in Javascript " and not the backslash. So, here is the code to remove all slashes from a string in JavaScript.

str = '/mobiles-phones/.png';
str.replace(/\//g, "")//output would be "mobiles-phones.png";
+6
source

JavaScript '9.61 ' 9:61?

var str = "one thing\\\ for certain: power blackouts and surges can damage your equipment.";

str.replace("\", "");
0
source

Regexs are big str.replace(/\\/g,'')

0
source

All Articles