// 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)(.+\n.+\n)(\d+\.\d{1,2})").unwrap();
let string = "RETAIL
UPRICE QTY TOTAL
ILLUSTRATION BOARD 15X20 (1/4 SIZE ) BY
1276
12.50 1.0 12.50
MONGOL PENCIL 1,2,3 PC
434
6.50 1.0 6.50
MS 300 (MGK) PERMANENT MARKER
1470
3.75 1.0 3.75
HBW White Glue 40 grans
1690
10.00 1.0 10.00
COLOR PEN 8 COLORS (VARIOUS BRAND)
1930
16.50 1.0 16.50
KS /CREATION CONSTRUCTION PAPER (105)
3503
23.00 1.0 23.00";
// 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/