{"ScriptPreparationCode":"const urls = [\r\n\u0022/v1/tron/instruments/PVCM/composition\u0022,\r\n\u0022/v1/tron/instruments/Otro/composition\u0022,\r\n\u0022/v1/tron/instruments/Serabe/composition\u0022,\r\n\u0022/v1/tron/instruments/PVCM/compositon\u0022,\r\n];\r\n\r\nconst results = [\u0027PVCM\u0027, \u0027Otro\u0027, \u0027Serabe\u0027, false];","TestCases":[{"Name":"String handling","Code":"const urls = [\r\n\u0022/v1/tron/instruments/PVCM/composition\u0022,\r\n\u0022/v1/tron/instruments/Otro/composition\u0022,\r\n\u0022/v1/tron/instruments/Serabe/composition\u0022,\r\n\u0022/v1/tron/instruments/PVCM/compositon\u0022,\r\n];\r\n\r\nconst results = [\u0027PVCM\u0027, \u0027Otro\u0027, \u0027Serabe\u0027, false];\r\n\r\nconst extractSegment = (url) =\u003E {\r\n if (!url.startsWith(\u0027/v1/tron/instruments/\u0027)) {\r\n return false;\r\n }\r\n \r\n if (!url.endsWith(\u0027/composition\u0027)) {\r\n return false;\r\n }\r\n \r\n const fragment = url.substring(\u0027/v1/tron/instruments/\u0027.length, url.length - \u0027/composition\u0027.length);\r\n \r\n if (fragment.includes(\u0027/\u0027)) {\r\n return false;\r\n }\r\n \r\n return fragment;\r\n}\r\nurls.forEach((url, idx) =\u003E {\r\n const fragment = extractSegment(url);\r\n \r\n if (fragment !== results[idx]) {\r\n throw \u0060Mismatch #{fragment} #{results[idx]}\u0060;\r\n }\r\n});","IsDeferred":false},{"Name":"Simple Regex","Code":"const urls = [\r\n\u0022/v1/tron/instruments/PVCM/composition\u0022,\r\n\u0022/v1/tron/instruments/Otro/composition\u0022,\r\n\u0022/v1/tron/instruments/Serabe/composition\u0022,\r\n\u0022/v1/tron/instruments/PVCM/compositon\u0022,\r\n];\r\n\r\nconst results = [\u0027PVCM\u0027, \u0027Otro\u0027, \u0027Serabe\u0027, false];\r\n\r\nconst regexp = new RegExp(\u0027\\/v1\\/tron\\/instruments\\/([^\\]\u002B)\\/composition\u0027, \u0022i\u0022)\r\n\r\nurls.forEach((url, idx) =\u003E {\r\n const match = url.match(regexp);\r\n if (typeof results[idx] === \u0027string\u0027) {\r\n if (match[1] !== results[idx]) {\r\n throw \u0060Wrong #{match[1]} #{results[idx]}\u0060;\r\n }\r\n } else if (results[idx] === false) {\r\n if (match !== null) {\r\n throw \u0060Wrong, #{match} found\u0060;\r\n }\r\n }\r\n});","IsDeferred":false},{"Name":"Anchored Regex","Code":"const urls = [\r\n\u0022/v1/tron/instruments/PVCM/composition\u0022,\r\n\u0022/v1/tron/instruments/Otro/composition\u0022,\r\n\u0022/v1/tron/instruments/Serabe/composition\u0022,\r\n\u0022/v1/tron/instruments/PVCM/compositon\u0022,\r\n];\r\n\r\nconst results = [\u0027PVCM\u0027, \u0027Otro\u0027, \u0027Serabe\u0027, false];\r\n\r\nconst regexp = new RegExp(\u0027^\\/v1\\/tron\\/instruments\\/([^\\]\u002B)\\/composition$\u0027, \u0022i\u0022)\r\n\r\nurls.forEach((url, idx) =\u003E {\r\n const match = url.match(regexp);\r\n if (typeof results[idx] === \u0027string\u0027) {\r\n if (match[1] !== results[idx]) {\r\n throw \u0060Wrong #{match[1]} #{results[idx]}\u0060;\r\n }\r\n } else if (results[idx] === false) {\r\n if (match !== null) {\r\n throw \u0060Wrong, #{match} found\u0060;\r\n }\r\n }\r\n});","IsDeferred":false}]}