// 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"(process)+(.*)(\n.*)*(?=Edition)").unwrap();
let string = "Throughout the book we’ve seen a variety of ways in which the shell processes input lines, especially using read. We can think of this process as a subset of the things the shell does when processing
command lines. This appendix provides a more detailed description of the steps involved in processing the command line and
how you can get bash to make a second pass with eval. The material in this appendix also appears in Learning the bash Shell, 3rd Edition, by Cameron Newham (O’Reilly).";
// 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/