const regex = /(?<=var\svars).*(?=\\n\\nif \(!var)/mis;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?<=var\\svars).*(?=\\\\n\\\\nif \\(!var)', 'mis')
const str = `;\\n}\\nvar vars = {\\"uid\\":\\"170785079\\",\\"vid\\":171461352,\\"oid\\":170785079,\\"host\\":509202,\\"vtag\\":\\"493bf2f9dd\\",\\"ltag\\":\\"l_8f6ca452\\",\\"vkid\\":171461352,\\"md_title\\":\\"6dfdbda80019208839183a713f243a41\\",\\"md_author\\":\\"Ayxan Əmiraslanl\\",\\"author_id\\":170785079,\\"author_href\\":\\"\\\\\\/mr.ayxan\\",\\"hd\\":3,\\"no_flv\\":1,\\"hd_def\\":-1,\\"dbg_on\\":0,\\"t\\":\\"\\",\\"duration\\":244,\\"angle\\":0.000000,\\"img_angle\\":0.000000,\\"repeat\\":0,\\"show_ads_preroll\\":0,\\"show_ads_postroll\\":0,\\"show_ads_promo_preroll\\":0,\\"show_ads_overlay\\":0,\\"ads_type\\":-1,\\"legal_owner\\":0,\\"eid1\\":0,\\"slot\\":0,\\"g\\":1,\\"a\\":18,\\"puid34\\":0,\\"water_mark\\":\\"\\",\\"can_rotate\\":1,\\"hash\\":\\"19e3bc2d2ae2f2ce34f6fbaefcf93e2d\\",\\"hash2\\":\\"246f9680b9b4f835\\",\\"is_vk\\":\\"1\\",\\"is_ext\\":\\"0\\",\\"referrer\\":\\"\\",\\"c3\\":\\"\\",\\"sample_id\\":-1,\\"cat_id\\":13,\\"sitezone\\":17,\\"ads_preview\\":0,\\"puid4\\":0,\\"puid5\\":14,\\"puid6\\":86,\\"pl_type\\":\\"other\\",\\"nolikes\\":1,\\"lang_add\\":\\"Add to My Videos\\",\\"lang_added\\":\\"Video added to My Videos\\",\\"lang_share\\":\\"Share\\",\\"lang_like\\":\\"Like\\",\\"lang_subscribe\\":\\"Subscribe\\",\\"lang_subscribed\\":\\"You have subscribed\\",\\"lang_volume_on\\":\\"Unmute\\",\\"lang_volume_off\\":\\"Mute\\",\\"lang_volume\\":\\"Volume\\",\\"lang_hdsd\\":\\"Change Video Quality\\",\\"lang_quality_auto\\":\\"Auto\\",\\"lang_open_popup\\":\\"Expand\\",\\"lang_fullscreen\\":\\"Full Screen\\",\\"lang_window\\":\\"Minimize\\",\\"lang_rotate\\":\\"Rotate\\",\\"lang_ads_link\\":\\"Advertiser's Site\\",\\"lang_ads\\":\\"Ads\\",\\"lang_ads_skip\\":\\"Skip ad\\",\\"lang_ads_skip_time\\":\\"Skip ads in {time} s\\",\\"lang_report_problem\\":\\"Report a problem..\\",\\"lang_replay\\":\\"Replay\\",\\"lang_next_cancel\\":\\"Cancel\\",\\"video_play_hd\\":\\"Watch in HD\\",\\"video_stop_loading\\":\\"Stop Download\\",\\"video_player_version\\":\\"VK Video Player\\",\\"goto_orig_video\\":\\"Go to Video\\",\\"video_get_video_code\\":\\"Copy video code\\",\\"video_load_error\\":\\"The video has not uploaded yet or the server is not available\\",\\"video_get_current_url\\":\\"Copy frame link\\",\\"lang_next\\":\\"Next video\\",\\"url240\\":\\"https:\\\\\\/\\\\\\/cs509202.vk.me\\\\\\/8\\\\\\/u170785079\\\\\\/videos\\\\\\/493bf2f9dd.240.mp4?extra=SatA0TNoxI3a5jCGpYqhL9FIoS9kjnfIqvkVswFVnFDqJToNiAidxUb2ELSSrSEBNGEvU9Fiseuq5uEQSS_-afULYhnmxc6_vvsCA0mWSYbxDux-HA\\",\\"url360\\":\\"https:\\\\\\/\\\\\\/cs509202.vk.me\\\\\\/8\\\\\\/u170785079\\\\\\/videos\\\\\\/493bf2f9dd.360.mp4?extra=SatA0TNoxI3a5jCGpYqhL9FIoS9kjnfIqvkVswFVnFDqJToNiAidxUb2ELSSrSEBNGEvU9Fiseuq5uEQSS_-afULYhnmxc6_vvsCA0mWSYbxDux-HA\\",\\"url480\\":\\"https:\\\\\\/\\\\\\/cs509209.vk.me\\\\\\/8\\\\\\/u170785079\\\\\\/videos\\\\\\/493bf2f9dd.480.mp4?extra=SatA0TNoxI3a5jCGpYqhL9FIoS9kjnfIqvkVswFVnFDqJToNiAidxUb2ELSSrSEBNGEvU9Fiseuq5uEQSS_-afULYhnmxc6_vvsCA0mWSYbxDux-HA\\",\\"url720\\":\\"https:\\\\\\/\\\\\\/cs509209.vk.me\\\\\\/8\\\\\\/u170785079\\\\\\/videos\\\\\\/493bf2f9dd.720.mp4?extra=SatA0TNoxI3a5jCGpYqhL9FIoS9kjnfIqvkVswFVnFDqJToNiAidxUb2ELSSrSEBNGEvU9Fiseuq5uEQSS_-afULYhnmxc6_vvsCA0mWSYbxDux-HA\\",\\"jpg\\":\\"https:\\\\\\/\\\\\\/pp.vk.me\\\\\\/c633320\\\\\\/v633320079\\\\\\/10dcc\\\\\\/GDFulD47LS8.jpg\\",\\"timeline_thumbs\\":1,\\"timeline_thumbs_jpg\\":\\"https:\\\\\\/\\\\\\/pp.vk.me\\\\\\/c628028\\\\\\/v628028079\\\\\\/363df\\\\\\/FVHRrSkD6HM.jpg,https:\\\\\\/\\\\\\/pp.vk.me\\\\\\/c633322\\\\\\/v633322079\\\\\\/f06a\\\\\\/CjskgJb-xxU.jpg\\",\\"timeline_thumbs_per_row\\":10,\\"timeline_thumbs_per_image\\":100,\\"timeline_thumbs_total\\":122,\\"timeline_thumb_width\\":133.000000,\\"timeline_thumb_height\\":75,\\"ip_subm\\":1,\\"proxy\\":\\"psv4\\",\\"https\\":1,\\"viewer_id\\":170785079,\\"nologo\\":1,\\"show_next\\":0,\\"show_suggestions\\":0,\\"liked\\":0,\\"add_hash\\":\\"0685c16b426a731323\\",\\"added\\":0,\\"can_add\\":0,\\"no_title\\":0,\\"vsegs_size\\":24.000000,\\"vsegs_hash\\":\\"1433edfd589e9d072b\\",\\"module\\":\\"direct\\",\\"playlist_id\\":null};\\n\\nif (!var`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions