문제

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

도움이 되었습니까?

해결책

Use a simple regex to solve it

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

Demo: Fiddle

다른 팁

This is the answer according to the title as the title is "Remove all slashes in Javascript" not backslashes. So here is the code to remove all the slashes from a string in JavaScript.

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

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

How do I do string replace in JavaScript to convert ‘9.61’ to ‘9:61’?

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

str.replace("\", "");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top