How to convert a string with escaped characters into a "normal" string
- by M28
Let's say that I have like this: "\\n", I need to convert it to a string like if the interpreter would do it: \n.
A simple replace like this wouldn't work:
function aaa(s){
return s.replace(/\\n/gm,'\n').replace(/\\\\/gm,'\\');
}
I need this behaviour:
"Line 1\nLine 2" = Line 1<Line break>Line 2
"Line 1\\nLine 1" = Line 1\nLine1