Hello
There seems to be an issue with Node's implementation of replace. The behavior appears to escape the backslashes; please see the output below:
> dev twong$ node -v
v4.0.0
nyl7twong:dev twong$ node
> a = "\\a\\b";
'\\a\\b'
> a.replace(/\\\\/g, '\*')
'\\a\\b'
> a.replace(/\\/g, '\*')
'*a*b'
> a.replace(/\\/g, '\\')
'\\a\\b'
Now using node v4.1.2
nyl7twong:dev twong$ node -v
v4.1.2
nyl7twong:dev twong$ node
> a = "\\a\\b";
'\\a\\b'
> a.replace(/\\\\/g, '\*')
'\\a\\b'
> a.replace(/\\/g, '\*')
'*a*b'
> a.replace(/\\/g, '\\')
'\\a\\b'
Chrome's output (via console)
a = "\\a\\b"
"\a\b"
a
"\a\b"
a = "\\\\a\\\\b"
"\\a\\b"
a.replace(/\\\\/g, '\\');
"\a\b"
Hello
There seems to be an issue with Node's implementation of replace. The behavior appears to escape the backslashes; please see the output below:
Chrome's output (via console)