Remove all backslashes in Javascript

user2046091 picture user2046091 · Apr 23, 2013 · Viewed 55k times · Source

How to remove all backslash in a JavaScript string ?

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

I want output like

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

Update:

I am scrapping data from page with help of JavaScript & displaying on fancy-box popup.

please help me on this

Answer

Arun P Johny picture Arun P Johny · Apr 23, 2013

Use a simple regex to solve it

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

Demo: Fiddle