var strObj = '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n{"text": true, ["text", "text", "text", "text"], [{ "text", "text" }]}\n\n\n'
I try to misinform the string by deleting \n, but when I do .replace(/\\\n/g, ''), it doesn't seem to catch it. I also searched Google and found:
.. according to JavaScript regular expression syntax, you need two backslash characters in your regular expression literals, such as /\\/or /\\/g.
But even when I test the expression just to break the backslash, it returns false:
(/\\\/g).test(strObj)
RegEx tester fixes \ncorrectly: http://regexr.com/3d3pe
source
share