// 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"(?mi)structure|(constant\s+?maturity\s+?|CMS|CMT)|inverse\s+?floater|snow\w+|steepener|flattener|(digital|callable|accrual|CRANS)|(variance|volatility)|quanto|trigger").unwrap();
let string = "• Anything with “Structured Note”
• Anything with “Constant Maturity swap” or “CMS” (i.e., “CMS” or “CMS option”)
• Anything with “Constant Maturity Treasuries” or “CMT” (i.e., “CMT swaps or CMT swaptions”)
• Anything with “Inverse floater” inverse floater
• Anything with “Snowball”
• Anything with “Steepener”
• Anything with “Flattener”
• Anything with “Digital and Callable Range Accrual Notes” (“CRANS”)
• Anything with “Variance” or “Volatility” in connection with “swap”
• Anything describing a “Quanto” swap or swaption
• Anything describing a “Trigger” swap or swaption
";
// 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/