{"ScriptPreparationCode":"function getCookieIX(name,str){\r\n name = name\u002B\u0027=\u0027;\r\n var ck = str || document.cookie;\r\n var idx = ck.lastIndexOf(name);\r\n if(idx==-1){ return undefined}\r\n var nameLength = name.length;\r\n var p1 = ck.substring(idx\u002BnameLength);\r\n var idx2 = p1.indexOf(\u0027;\u0027);\r\n if(idx2\u003E-1){\r\n p1 = p1.substring(0,idx2);\r\n }\r\n return p1;\r\n}\r\n\r\nfunction getCookieIX2(name, str) {\r\n name = name \u002B \u0022=\u0022;\r\n var ck = str || document.cookie;\r\n ck = \u0022; \u0022 \u002B ck;\r\n // support if the \r\n var ckLC = ck.toLowerCase();\r\n var idx = ckLC.lastIndexOf(\u0022; \u0022 \u002B name.toLowerCase());\r\n if (idx == -1) {\r\n return undefined;\r\n }\r\n var nameLength = name.length;\r\n var p1 = ck.substring(idx \u002B nameLength);\r\n var idx2 = p1.indexOf(\u0022;\u0022);\r\n if (idx2 \u003E -1) {\r\n p1 = p1.substring(0, idx2);\r\n p1 = decodeURIComponent(p1);\r\n return p1;\r\n }\r\n return p1;\r\n}\r\n\r\nfunction getCookie(name) {\r\n var nameEQ = name \u002B \u0022=\u0022;\r\n var ca = document.cookie.split(\u0022;\u0022);\r\n for (var i = 0; i \u003C ca.length; i\u002B\u002B) {\r\n var c = ca[i];\r\n while (c.charAt(0) == \u0022 \u0022) c = c.substring(1, c.length);\r\n if (c.indexOf(nameEQ) == 0) {\r\n var d = c.substring(nameEQ.length, c.length);\r\n d = decodeURIComponent(d);\r\n return d;\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\nfunction getCookieM(name) {\r\n name = name \u002B \u0022\u0022;\r\n var re = new RegExp(\u0022(^| )\u0022 \u002B name \u002B \u0022=([^;]\u002B)\u0022, \u0022gmi\u0022);\r\n var m = document.cookie.match(re);\r\n if (!!m) {\r\n m = m.pop();\r\n m = m.substring(m.indexOf(\u0022=\u0022) \u002B 1);\r\n m = !!m ? decodeURIComponent(m) : m;\r\n return m;\r\n }\r\n}\r\n\r\nfunction getCookieW(name, str) {\r\n var str = str || document.cookie;\r\n var re = new RegExp(\u0022(?:^|; )(\u0022\u002Bname\u002B\u0022\u002B?)(?:=([^;]*))?(?:;|$)\u0022, \u0022gi\u0022);\r\n var value;\r\n var match;\r\n while ((match = re.exec(str))) {\r\n re.lastIndex = match.index \u002B match.length - 1;\r\n var k = match[1];\r\n var v = decodeURIComponent(match[2]);\r\n !!v \u0026\u0026 (value = v);\r\n }\r\n\r\n return value;\r\n}\r\n\r\ndocument.cookie = \u0022foo=bar\u0022;\r\ndocument.cookie = \u0022foo=nope;domain=measurethat.net\u0022;","TestCases":[{"Name":"Original","Code":"getCookie(\u0027foo\u0027)","IsDeferred":false},{"Name":"Regex","Code":"getCookieM(\u0027foo\u0027)","IsDeferred":false},{"Name":"RegexLoop","Code":"getCookieW(\u0027foo\u0027)","IsDeferred":false},{"Name":"LastIndexOf","Code":"getCookieIX(\u0027foo\u0027)","IsDeferred":false},{"Name":"LastindexOf2","Code":"getCookieIX2(\u0027foo\u0027)","IsDeferred":false}]}