// 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)^.*?Python Regular Expression.*?$(*SKIP)(*FAIL)|^.*?Python Proprietary.*?$(*SKIP)(*FAIL)|.*?Page \d+.*?$(*SKIP)(*FAIL)|^$(*SKIP)(*FAIL)|^.*?$").unwrap();
let string = "This module provides regular expression matching operations.
Regular expressions use the backslash character ('\\') to indicate special forms
or to allow special characters to be used without invoking their special
meaning.
Python Regular Expression 02 December 1999
Python Proprietary
----------------------- Page 292-----------------------
PYTHON RE SPECIFICATION Version 2.7 [Vol 9, Part Q] page 983
Python Regular Expression Specification
It is important to note that most regular expression operations are available as
module-level functions and RegexObject methods. The functions are shortcuts that
don’t require you to compile a regex object first, but miss some fine-tuning
parameters.";
// 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/