// 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 .* = '(.*?)';").unwrap();
let string = "<script type=\"text/javascript\">
var NVRAMyandex = 'Close'; NVRAM_wan_static_dns_profile_yandex = (NVRAM_wan_static_dns_profile_yandex !='') ? NVRAM_wan_static_dns_profile_yandex : 'basic';
var FancyboxI18nClose = 'Close';
var FancyboxI18nNext = 'Next';
var FancyboxI18nPrev = 'Previous';
var PS_CATALOG_MODE = false;
var ajaxsearch = true;
var attribute_anchor_separator = '-';
var blocksearch_type = 'top';
var combinationsFromController = {\"163972\":{\"attributes_values\":{\"15\":\"40\"},\"attributes\":[75],\"price\":0,\"specific_price\":false,\"ecotax\":0,\"weight\":0.6,\"quantity\":1,\"reference\":\"IDP20059--IDPA163972\",\"unit_impact\":0,\"minimal_quantity\":\"1\",\"date_formatted\":\"\",\"available_date\":\"\",\"id_image\":-1,\"list\":\"'75'\"}};
var comparator_max_item = 0;
</script>";
// 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/