// 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#"(?<ChapterAuthors>[A-Z'a-z,\s]+?)(?: et al)?:(?<ChapterTitle>[A-Za-z,#\(\)\/0-9"’'&\sö]+)\.\s?In\s?(?<BookAuthors>[A-Za-z,\s]+?)(?: et al)?:(?<BookTitle>[A-Za-z,#\(\)0-9"’'&\s]+)\.\s?(?<Edition>\d+(?:rd|nd|st|th)\s(?:[eE]d|[eE]dition|))\.(?<Location>[-A-Za-z,.\s]+):(?<Publisher>[-A-Za-z,\(\)\/&\s]+)[\.]\s?(?<StartPage>\w?\d+\w?)-\s?(?<EndPage>\w?\d+\w?)[,\.;]\s?(?<Year>\d{4})"#).unwrap();
let string = "Johnson M: Amino acids and proteins. In Burtis CA et al: Tietz Fundamentals of Clinical Chemistry. 6th ed. St. Louis: Saunders. 286-310, 2008
Dufour DR: Liver disease. In Burtis CA et al: Tietz Fundamentals of Clinical Chemistry. 6th ed. St. Louis: Saunders. 675-95, 2008
Cunningham FG et al: Diseases and abnormalities of the placenta. In: Licht J, ed. Williams's obstetrics. 19th ed. Norwalk, Conn: Appleton & Lange. 748-59, 1993
Tille PM: Enterobacteriaceae. In Tille PM: Bailey & Scott’s Diagnostic Microbiology. 13th ed. St. Louis: Mosby. 307-28, 2013";
// 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/