// 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)(?<=Set-Cookie: __RequestVerificationToken=).{108}").unwrap();
let string = "HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Set-Cookie: __RequestVerificationToken=6JBpdPLoWg2ON0CbCTTCffsZZsCU_rRGlmarVTRfg4Gu1_6FEqpgd_jcLbN_mBWdXJjCeYw6DQ3nxd8hABsNTpRWJALapk9KUZhu6jGkh0I1; path=/; HttpOnly
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
strict-transport-security: max-age=60; includeSubDomains
referrer-policy: strict-origin-when-cross-origin
Set-Cookie: httpOnly
X-Content-Security-Policy: script-src 'self' https://fonts.gstatic.com
Date: Wed, 12 Feb 2020 15:46:34 GMT
Content-Length: 3124";
// 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/