prasad - 2 months ago 7
HTML Question

# Regex match with '\' slash and replace with '\\'?

I was converting normal string in to latex format.So i was created the latex code match and replace the

\
single slash into
\\
double slash.why the i need it Refer this link.I tried Below code :

function test(){
var tex="$$\left[ x=\left({{11}\over{2}}+{{\sqrt{3271}}\over{2\,3^{{{3}\over{2}$$";
var tex_form = tex.replace("/[\\\/\\\\\.\\\\]/g", "\\");
document.getElementById('demo').innerHTML=tex_form;//nothing get
}
test();

<p id="demo"></p>

Not getting any output data.But the match in this link

i wish to need replace the
\
into
\\

As the question you link to says, the \ character has special meaning inside a JavaScript string literal. It represents an escape sequence.
If you want to put a slash character in your string, then you need to write the escape sequence for it (the \\) in the source code. You can't add them back in with JavaScript afterwards.