{"ScriptPreparationCode":"var shortString = \u0022Short string without newline\u0022;\r\nvar longString = \u0022This is a very long string that represents a large amount of text data potentially copied from a web upload form. It does not contain any newline characters initially but we want to check the performance impact of running a regex replace vs a simple indexOf check.\u0022;\r\nvar longStringWithNewline = longString \u002B \u0022\\n\u0022 \u002B longString;\r\nvar regex = /\\r\\n|\\n/;","TestCases":[{"Name":"_.replace","Code":"_.replace(longString, regex, \u0027\u0027);","IsDeferred":false},{"Name":".indexOf(/n)","Code":"if (longString.indexOf(\u0027\\n\u0027) \u003E -1 || longString.indexOf(\u0027\\r\u0027) \u003E -1) {\r\n longString.replace(regex, \u0027\u0027);\r\n}","IsDeferred":false}]}