// 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)\d*[a|b]\d\d").unwrap();
let string = "1a01 Ὁμώνυμα λέγεται ὧν ὄνομα μόνον κοινόν, ὁ δὲ κατὰ
1a02 τοὔνομα λόγος τῆς οὐσίας ἕτερος, οἷον ζῷον ὅ τε ἄνθρω–
1a03 πος καὶ τὸ γεγραμμένον· τούτων γὰρ ὄνομα μόνον κοινόν,
1a04 ὁ δὲ κατὰ τοὔνομα λόγος τῆς οὐσίας ἕτερος· ἐὰν γὰρ
1a05 ἀποδιδῷ τις τί ἐστιν αὐτῶν ἑκατέρῳ τὸ ζῴῳ εἶναι, ἴδιον
1a06 ἑκατέρου λόγον ἀποδώσει.
1a06 συνώνυμα δὲ λέγεται ὧν τό τε
1a07 ὄνομα κοινὸν καὶ ὁ κατὰ τοὔνομα λόγος τῆς οὐσίας ὁ αὐτός,
1a08 οἷον ζῷον ὅ τε ἄνθρωπος καὶ ὁ βοῦς· τούτων γὰρ ἑκάτερον
1a09 κοινῷ ὀνόματι προσαγορεύεται ζῷον, καὶ ὁ λόγος δὲ
1a10 τῆς οὐσίας ὁ αὐτός· ἐὰν γὰρ ἀποδιδῷ τις τὸν ἑκατέρου
1a11 λόγον τί ἐστιν αὐτῶν ἑκατέρῳ τὸ ζῴῳ εἶναι, τὸν αὐτὸν
1a12 λόγον ἀποδώσει. ";
// 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/