// 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)(?<=\(\d{4}\)\.\s).+?(?=\,\s\d)").unwrap();
let string = "Супонина, А.Т., Петров, Б.А. (2021). Политическая мораль современной российской молодежи: ценности, представления, установки. Научный результат. Общество: политика, экономика, право, 3 (92), 19–22.
Шестопал, Е.Б., Рогач, Н.Н. (2020). Идеальные представления как фактор восприятия реального политического лидера. Полис. Политические исследования, 4, 166–180. DOI: 10.17976/jpps/2020.04.12";
// 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/