{"ScriptPreparationCode":"var text = \u0022fo\u0022.repeat(2000)\r\nvar oldText = \u0022o\u0022\r\nvar newText = \u0022u\u0022\r\nvar oldTextRegexp = new RegExp(oldText, \u0027g\u0027)\r\nvar occurrence = 700","TestCases":[{"Name":"repeat unitl","Code":"var substr\r\nvar i = occurrence\r\nvar result = text\r\nwhile ((substr = oldTextRegexp.exec(text)) !== null) {\r\n if (--i === 0) {\r\n result = text.slice(0, substr.index) \u002B newText \u002B text.slice(oldTextRegexp.lastIndex)\r\n break;\r\n }\r\n}\r\n","IsDeferred":false},{"Name":"replace callback","Code":"var i = 0\r\nvar result = text.replace(oldTextRegexp, function (match) {\r\n \u002B\u002Bi\r\n if (i === occurrence) {\r\n return newText\r\n } else {\r\n return match\r\n }\r\n})","IsDeferred":false}]}