-1

I am trying to remove every backslash of a string for an hour, but I cannot make it work.

Here is my string for instance:

[{\"file\":\"https:\\/n-adsadele.stjkwgjkw.co\/adwq

Here is what I tried:

const replaced = toString.replace(String.fromCharCode(92), String.fromCharCode(32));
const replaced = toString.replace("\\\\", "");
const replaced = toString.replace("\\", "");
const replaced = toString.replace(/\\/, "");

All of this does absolutely nothing.

Zakaria Acharki
  • 66,747
  • 15
  • 75
  • 101
Jerlam
  • 943
  • 2
  • 12
  • 31

1 Answers1

3

You could use regex simply like :

var toString = '[{\"file\":\"https:\\/n-adsadele.stjkwgjkw.co\/adwq';

console.log(toString.replace(/\\/g, ""));
Zakaria Acharki
  • 66,747
  • 15
  • 75
  • 101