// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r"(?m)(?<=var config = )(.*?)(?=; if \(!config.request\) {)").unwrap();
let string = "<!DOCTYPE html> <html lang=\"en\"> <head> <meta charset=\"utf-8\"> <meta name=\"viewport\" content=\"width=device-width,initial-scale=1,user-scalable=yes\"> <meta name=\"robots\" content=\"noindex\"> <title>Institutional Trading - Cross Pair Manipulation Example(2) from FX on Vimeo</title> <style> body, html, .player, .fallback { overflow: hidden; width: 100%; height: 100%; margin: 0; padding: 0; background-color: transparent; } .player.loading { opacity: 0; } </style> <script> !function(){if('PerformanceLongTaskTiming' in window){var g=window.__tti={e:[]}; g.o=new PerformanceObserver(function(l){g.e=g.e.concat(l.getEntries())}); g.o.observe({entryTypes:['longtask']})}}(); </script> <!--[if IE]><script>var cacheBuster = '?' + Math.round((Math.random() * 1000) + new Date().getTime());</script><![endif]--> </head> <body> <div class=\"vp-placeholder\"> <style> .vp-placeholder, .vp-placeholder-thumb, .vp-placeholder-thumb::before, .vp-placeholder-thumb::after { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } .vp-placeholder { visibility: hidden; width: 100%; max-height: 100%; height: calc(720 / 1278 * 100vw); max-width: calc(1278 / 720 * 100vh); margin: auto; } .vp-placeholder-carousel { display: none; background-color: #000; position: absolute; left: 0; right: 0; bottom: -60px; height: 60px; } </style> <div class=\"vp-placeholder-thumb\"></div> <div class=\"vp-placeholder-carousel\"></div> <script> (function(document) { var placeholder = document.querySelector('.vp-placeholder'); var placeholderThumb = document.querySelector('.vp-placeholder-thumb'); var videoWidth = parseInt('1278'); var videoHeight = parseInt('720'); placeholder.style.visibility = 'visible'; }(document)); </script> </div> <div id=\"player\" class=\"player\"></div> <script> (function(document, player) { var config = {\"cdn_url\":\"https://f.vimeocdn.com\",\"vimeo_api_url\":\"api.vimeo.com\",\"request\":{\"files\":{\"dash\":{\"separate_av\":true,\"streams\":[{\"profile\":165,\"quality\":\"540p\",\"id\":\"d224c998-be2d-4dc2-b557-2561a12b7e17\",\"fps\":30},{\"profile\":139,\"quality\":\"240p\",\"id\":\"54c8bc86-a831-4448-95f4-911e0ea7d614\",\"fps\":30},{\"profile\":164,\"quality\":\"360p\",\"id\":\"c40ef745-5410-4d6a-b63a-5d866a84631a\",\"fps\":30},{\"profile\":174,\"quality\":\"720p\",\"id\":\"89da344d-e3b9-4057-bdc1-93c02796c4d4\",\"fps\":30}],\"cdns\":{\"akfire_interconnect_quic\":{\"url\":\"https://39vod-adaptive.akamaized.net/exp=1613913431~acl=%2F34723841-8453-4a14-99fc-18deeea2b7ee%2F%2A~hmac=d94c3e5319eb1ac5132dc7885076fbb7c14fd0f006cb272bfc5403b96cf1feb3/34723841-8453-4a14-99fc-18deeea2b7ee/sep/video/d224c998,54c8bc86,c40ef745,89da344d/master.json?base64_init=1\",\"origin\":\"gcs\",\"avc_url\":\"https://39vod-adaptive.akamaized.net/exp=1613913431~acl=%2F34723841-8453-4a14-99fc-18deeea2b7ee%2F%2A~hmac=d94c3e5319eb1ac5132dc7885076fbb7c14fd0f006cb272bfc5403b96cf1feb3/34723841-8453-4a14-99fc-18deeea2b7ee/sep/video/d224c998,54c8bc86,c40ef745,89da344d/master.json?base64_init=1\"}},\"streams_avc\":[{\"profile\":165,\"quality\":\"540p\",\"id\":\"d224c998-be2d-4dc2-b557-2561a12b7e17\",\"fps\":30},{\"profile\":139,\"quality\":\"240p\",\"id\":\"54c8bc86-a831-4448-95f4-911e0ea7d614\",\"fps\":30},{\"profile\":164,\"quality\":\"360p\",\"id\":\"c40ef745-5410-4d6a-b63a-5d866a84631a\",\"fps\":30},{\"profile\":174,\"quality\":\"720p\",\"id\":\"89da344d-e3b9-4057-bdc1-93c02796c4d4\",\"fps\":30}],\"default_cdn\":\"akfire_interconnect_quic\"},\"hls\":{\"separate_av\":true,\"default_cdn\":\"akfire_interconnect_quic\",\"cdns\":{\"akfire_interconnect_quic\":{\"url\":\"https://39vod-adaptive.akamaized.net/exp=1613913431~acl=%2F34723841-8453-4a14-99fc-18deeea2b7ee%2F%2A~hmac=d94c3e5319eb1ac5132dc7885076fbb7c14fd0f006cb272bfc5403b96cf1feb3/34723841-8453-4a14-99fc-18deeea2b7ee/sep/video/54c8bc86,89da344d,c40ef745,d224c998/master.m3u8\",\"origin\":\"gcs\",\"avc_url\":\"https://39vod-adaptive.akamaized.net/exp=1613913431~acl=%2F34723841-8453-4a14-99fc-18deeea2b7ee%2F%2A~hmac=d94c3e5319eb1ac5132dc7885076fbb7c14fd0f006cb272bfc5403b96cf1feb3/34723841-8453-4a14-99fc-18deeea2b7ee/sep/video/54c8bc86,89da344d,c40ef745,d224c998/master.m3u8\"}}},\"progressive\":[{\"profile\":139,\"width\":426,\"mime\":\"video/mp4\",\"fps\":30,\"url\":\"https://vod-progressive.akamaized.net/exp=1613913431~acl=%2Fvimeo-prod-skyfire-std-us%2F01%2F539%2F19%2F477696225%2F2133786017.mp4~hmac=0e58b05effaba29cd3c4e53cf0af5848e562d72b0f0a081d950e9e5e41bcfbec/vimeo-prod-skyfire-std-us/01/539/19/477696225/2133786017.mp4\",\"cdn\":\"akamai_interconnect\",\"quality\":\"240p\",\"id\":\"54c8bc86-a831-4448-95f4-911e0ea7d614\",\"origin\":\"gcs\",\"height\":240},{\"profile\":174,\"width\":1278,\"mime\":\"video/mp4\",\"fps\":30,\"url\":\"https://vod-progressive.akamaized.net/exp=1613913431~acl=%2Fvimeo-prod-skyfire-std-us%2F01%2F539%2F19%2F477696225%2F2133785961.mp4~hmac=1301914e2fb3b00f56be35e50f1985f12246971878570476cc06068bd0cf1a72/vimeo-prod-skyfire-std-us/01/539/19/477696225/2133785961.mp4\",\"cdn\":\"akamai_interconnect\",\"quality\":\"720p\",\"id\":\"89da344d-e3b9-4057-bdc1-93c02796c4d4\",\"origin\":\"gcs\",\"height\":720},{\"profile\":164,\"width\":640,\"mime\":\"video/mp4\",\"fps\":30,\"url\":\"https://vod-progressive.akamaized.net/exp=1613913431~acl=%2Fvimeo-prod-skyfire-std-us%2F01%2F539%2F19%2F477696225%2F2133785990.mp4~hmac=93fe040e3380a8aae49bfef8143974c789e575c2b88fb724f345640fe84c12f4/vimeo-prod-skyfire-std-us/01/539/19/477696225/2133785990.mp4\",\"cdn\":\"akamai_interconnect\",\"quality\":\"360p\",\"id\":\"c40ef745-5410-4d6a-b63a-5d866a84631a\",\"origin\":\"gcs\",\"height\":360},{\"profile\":165,\"width\":960,\"mime\":\"video/mp4\",\"fps\":30,\"url\":\"https://vod-progressive.akamaized.net/exp=1613913431~acl=%2Fvimeo-prod-skyfire-std-us%2F01%2F539%2F19%2F477696225%2F2133786016.mp4~hmac=6bc1e0a4431a8b53d0a10fc115613b36a39253668d88309acd01fe823a166877/vimeo-prod-skyfire-std-us/01/539/19/477696225/2133786016.mp4\",\"cdn\":\"akamai_interconnect\",\"quality\":\"540p\",\"id\":\"d224c998-be2d-4dc2-b557-2561a12b7e17\",\"origin\":\"gcs\",\"height\":540}]},\"lang\":\"en\",\"sentry\":{\"url\":\"https://6f5f8e1cecfa40fb850f578b69fc1705@o189131.ingest.sentry.io/1297650\",\"enabled\":true,\"debug_enabled\":true,\"debug_intent\":0},\"ab_tests\":{\"chromecast\":{\"track\":false,\"data\":{},\"group\":false},\"stats_fresnel\":{\"track\":false,\"data\":{},\"group\":true},\"webvr\":{\"track\":false,\"data\":{},\"group\":false}},\"referrer\":\"https://portal.forexlens.com/\",\"cookie_domain\":\".vimeo.com\",\"timestamp\":1613908359,\"gc_debug\":{\"bucket\":\"vimeo-player-debug\"},\"expires\":4772,\"client\":{\"ip\":\"220.101.72.10\"},\"currency\":\"AUD\",\"session\":\"5703ec432ce94f6bdbf9e1fdea7a7041ff26bf6a1613908359\",\"cookie\":{\"scaling\":1,\"volume\":1.0,\"quality\":null,\"hd\":0,\"captions\":null},\"build\":{\"backend\":\"1.30.0\",\"js\":\"3.24.15\"},\"urls\":{\"barebone_js\":\"https://f.vimeocdn.com/p/3.24.15/js/barebone.js\",\"test_imp\":\"https://fresnel.vimeocdn.com/add/player-test-impression\",\"js_base\":\"https://f.vimeocdn.com/p/3.24.15/js/\",\"fresnel\":\"https://fresnel.vimeocdn.com/add/player-stats\",\"js\":\"https://f.vimeocdn.com/p/3.24.15/js/player.js\",\"proxy\":\"https://player.vimeo.com/static/proxy.html\",\"mux_url\":\"https://f.vimeocdn.com/p/external/mux.js\",\"fresnel_mimir_inputs_url\":\"https://fresnel-events.vimeocdn.com/add/mimir_inputs\",\"fresnel_chunk_url\":\"https://fresnel-events.vimeocdn.com/add/chunk_downloads\",\"three_js\":\"https://f.vimeocdn.com/p/external/three.rvimeo.min.js\",\"vuid_js\":\"https://f.vimeocdn.com/js_opt/modules/utils/vuid.min.js\",\"fresnel_manifest_url\":\"https://fresnel-events.vimeocdn.com/add/playback_manifest\",\"chromeless_css\":\"https://f.vimeocdn.com/p/3.24.15/css/chromeless.css\",\"player_telemetry_url\":\"https://player-telemetry.vimeo.com/player-events\",\"chromeless_js\":\"https://f.vimeocdn.com/p/3.24.15/js/chromeless.js\",\"css\":\"https://f.vimeocdn.com/p/3.24.15/css/player.css\"},\"signature\":\"4699156845181997dda036015514218e\",\"flags\":{\"dnt\":0,\"preload_video\":\"metadata_on_hover\",\"plays\":1,\"partials\":1,\"autohide_controls\":0},\"country\":\"AU\",\"file_codecs\":{\"hevc\":{\"hdr\":[],\"sdr\":[]},\"av1\":[],\"avc\":[\"54c8bc86-a831-4448-95f4-911e0ea7d614\",\"89da344d-e3b9-4057-bdc1-93c02796c4d4\",\"c40ef745-5410-4d6a-b63a-5d866a84631a\",\"d224c998-be2d-4dc2-b557-2561a12b7e17\"]}},\"player_url\":\"player.vimeo.com\",\"video\":{\"version\":{\"current\":null,\"available\":[{\"is_current\":1,\"id\":172309594,\"file_id\":2133782839}]},\"height\":720,\"duration\":1193,\"thumbs\":{\"1280\":\"https://i.vimeocdn.com/video/992178104_1280.jpg\",\"960\":\"https://i.vimeocdn.com/video/992178104_960.jpg\",\"640\":\"https://i.vimeocdn.com/video/992178104_640.jpg\",\"base\":\"https://i.vimeocdn.com/video/992178104\"},\"owner\":{\"account_type\":\"live_premium\",\"name\":\"FX\",\"img\":\"https://i.vimeocdn.com/portrait/46550218_60x60.jpg?subrect=512%2C274%2C804%2C566&r=cover\",\"url\":\"https://vimeo.com/forexlens\",\"img_2x\":\"https://i.vimeocdn.com/portrait/46550218_120x120.jpg?subrect=512%2C274%2C804%2C566&r=cover\",\"id\":122503711},\"id\":477696225,\"embed_code\":\"<iframe title=\\\"vimeo-player\\\" src=\\\"https://player.vimeo.com/video/477696225\\\" width=\\\"640\\\" height=\\\"360\\\" frameborder=\\\"0\\\" allowfullscreen><\\/iframe>\",\"title\":\"Institutional Trading - Cross Pair Manipulation Example(2)\",\"share_url\":\"https://vimeo.com/477696225\",\"width\":1278,\"embed_permission\":\"whitelist\",\"fps\":30.0,\"spatial\":0,\"live_event\":null,\"allow_hd\":1,\"hd\":1,\"lang\":null,\"default_to_hd\":0,\"url\":null,\"privacy\":\"unlisted\",\"bypass_token\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGlwX2lkIjo0Nzc2OTYyMjUsImV4cCI6MTYxMzkxMzE1Mn0.S7o9I8F9HJbG6svHWXiL965ZZxxWH8NbR0o7Xh4-xbQ\",\"unlisted_hash\":\"faada2abe5\"},\"user\":{\"team_origin_user_id\":0,\"liked\":0,\"account_type\":\"none\",\"vimeo_api_client_token\":null,\"vimeo_api_interaction_tokens\":null,\"team_id\":0,\"watch_later\":0,\"owner\":0,\"id\":0,\"mod\":0,\"logged_in\":0},\"embed\":{\"autopause\":0,\"playsinline\":0,\"settings\":{\"fullscreen\":1,\"byline\":0,\"like\":0,\"playbar\":1,\"title\":0,\"color\":1,\"speed\":1,\"watch_later\":0,\"share\":0,\"scaling\":1,\"spatial_compass\":0,\"collections\":0,\"info_on_pause\":0,\"portrait\":0,\"logo\":0,\"embed\":0,\"badge\":0,\"spatial_label\":0,\"volume\":1},\"color\":\"00adef\",\"texttrack\":\"\",\"on_site\":0,\"app_id\":\"122963\",\"muted\":0,\"dnt\":0,\"player_id\":\"\",\"api\":null,\"editor\":false,\"context\":\"embed.main\",\"time\":0,\"outro\":\"beginning\",\"log_plays\":1,\"quality\":null,\"transparent\":1,\"loop\":0,\"autoplay\":1},\"view\":1,\"vimeo_url\":\"vimeo.com\"}; if (!config.request) { return; } if (typeof config.request === 'object' && 'error' in config.request) { if ('html' in config.request) { document.documentElement.innerHTML = config.request.html.replace(/</g, '<').replace(/>/g, '>'); } return; } var isIframe = (function() { try { return window.self !== window.top; } catch (e) { return true; } }()); if (!isIframe && /twitter/i.test(navigator.userAgent) && config.video.url) { window.location = config.video.url; } if (config.request.lang) { document.documentElement.setAttribute('lang', config.request.lang); } var fullscreenSupport = 'exitFullscreen' in document || 'webkitExitFullscreen' in document || 'webkitCancelFullScreen' in document || 'mozCancelFullScreen' in document || 'msExitFullscreen' in document || 'webkitEnterFullScreen' in document.createElement('video'); var inlineSvgSupport = (function() { var div = document.createElement('div'); div.innerHTML = '<svg/>'; return (div.firstChild && div.firstChild.namespaceURI) === 'http://www.w3.org/2000/svg'; }()); var windowsPhone = /MSIE 9/.test(navigator.userAgent) && /Windows Phone/.test(navigator.userAgent); var IE10 = /IE 10/.test(navigator.userAgent); var usePlayer = fullscreenSupport || IE10 || windowsPhone; var firstScript = document.getElementsByTagName('script')[0]; var script = document.createElement('script'); var jsDone = false; var playerObject = false; if (!inlineSvgSupport) { usePlayer = false; } if (!usePlayer) { var placeholder = document.querySelector('.vp-placeholder'); if (placeholder && placeholder.parentNode) { placeholder.parentNode.removeChild(placeholder); } } if (usePlayer) { player.className = 'player loading'; var startTime = new Date().getTime(); script.src = config.request.urls.js; firstScript.parentNode.insertBefore(script, firstScript); script['onreadystatechange' in script ? 'onreadystatechange' : 'onload'] = function() { if (!jsDone && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) { jsDone = true; playerObject = new VimeoPlayer(player, config, cssDone || { link: link, startTime: startTime }); } }; var cssDone = false; var link = document.createElement('link'); link.rel = 'stylesheet'; link.href = config.request.urls.css + (typeof cacheBuster === 'undefined' ? '' : cacheBuster); document.getElementsByTagName('head')[0].appendChild(link); link.onload = function() { cssDone = true; }; } else { player.innerHTML = '<div class=\"fallback\"><iframe title=\"vimeo-player\" src=\"/video/477696225/fallback?js&referrer=' + encodeURIComponent(config.request.referrer) + '\" frameborder=\"0\"></iframe></div>'; } if (!config.request.flags.dnt && !config.embed.dnt) { window._vuid = [ ['pid', config.request.session] ]; var vim = document.createElement('script'); vim.async = true; vim.src = config.request.urls.vuid_js; firstScript.parentNode.insertBefore(vim, firstScript); } }(document, document.getElementById('player'))); </script> </body> </html>
";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
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 Rust, please visit: https://docs.rs/regex/latest/regex/