// 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)\b(?i)[a-z-0-9‑]*?(?:plang|anlag|invest|warn|info|zukunft|design|enk|infra|insta|mënsch|liewens|vinyl|finnl|onge|längt|maintenance|dank|tank|vereinfach|einfach|fanger|gung|reng|keng|telefo|termin|ioun|immun|schwenk|nsl|lang|laang)[a-z-0-9‑]*?nn?[bcfgj-mp-sv-y](?!(chaft|ormatio|initi|eg(t|ung|e|s|itiv)))").unwrap();
let string = "MATCH:
nonsense|waning|cannnnns|banger|fancy
NO MATCH:
plang|anlag|invest|warn|zukunft|design|mënsch|längt|telefo|termin|ioun|immun
plangens
pplang|clanlags|infrared|amazukunft
cannon|wand|hone|banana
BUT: Zukunftsunpassung (should match 'unpass' but not 'zukunft' and not 'ung')
Eegenschaftsunklang (should match 'Unkl' but not 'Eegenschaft' and not 'klang')";
// 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/