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 am trying to sanitize a string by stripping out the \n
but when I do .replace(/\\\n/g, '')
it doesn't seem to catch it. I also Google searched and found:
..in accordance with 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 catch backslash, it returns false:
(/\\\/g).test(strObj)
RegEx tester captures \n
correctly: http://regexr.com/3d3pe