My string is
tel:\\99999999999
. How i can replace '\' to '\' single? I want output like: tel:\99999999999
.
Please see attached image backslashes not showing into question.
My string is
tel:\\99999999999
. How i can replace '\' to '\' single? I want output like: tel:\99999999999
.
Please see attached image backslashes not showing into question.
You should escape the slash twice:
"tel:\\99999999999".replace('\\\\', '\\');
use .replace()
to achieve what you want, str.replace("\\\\","\\")
var str = "tel:\\99999999999";
console.log(str.replace("\\\\","\\"))
You can simply use tel.replace(/\\\\/g, "\\")
.
Demo:
var tel ="\\99999999999";
console.log(tel.replace(/\\\\/g, "\\"));
You need to escape the \
character with another \
, because it's an escape character in JavaScript, you can check JavaScript backslash (\) in variables is causing an error for further reading.
You can do like this
"tel:\\99999999999".replace('\\\\', '');