// 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"(?miu)(?:^|(?<=.(?:[\s])))([л]+[\s-]*[о]+[\s-]*[х]+)+(?:$|[\s-])").unwrap();
let string = "лох плох ппп лох лоох ллох л о х
лох
плох
ппп
лох
лоох
ллох лох лохло х лохло хлам
л о х
л оо х
лоох
лox
лооx
лооох
плохо
неплохо
лохотрон
блоха
заглох
он оглох от взыва
он лоооох меня
он л-ох меня
он лОх меня
тыЛОХчего
металлохимия
маслохранилище
мой лохматый друг
лох";
// 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/