back soft

مطالب مرتبط با «how to convert binary to decimal» در back soft | نویسنده: استخدام کار

How to convert literal strings to their escape sequence equivalents? [duplicate]

Vote count: 15 I have this var var x = ""; Which is But I need How can I "unescape" this var to remove all escaping characters? asked Jul 10 '11 at 9:50BrunoLM 5 Answers Vote count: 22 accepted You can replace a backslash followed by a quote with just a quote via a regular expression and the String#replace function: var x = ""; x = x.replace(/\"/g, '"'); document.body.appendChild( document.createTextNode("After: " + x) ); Note that the regex just looks for one backslash; there are two in the literal because you have to escape backslashes in regular expression literals with a backslash (just like in a string literal). The g at the end of the regex tells replace to work throughout the string (...

ادامه مطلب