// 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*\.)?\d+$").unwrap();
let string = "
22/09/2015 11:05:41 | Dispense complete for COTTON, final dispense weight was 0.0262
22/09/2015 11:08:02 | Dispense complete for COTTON, final dispense weight was 0.0264
22/09/2015 11:10:08 | Dispense complete for COTTON, final dispense weight was 0.0229
22/09/2015 11:12:03 | Dispense complete for COTTON, final dispense weight was 0.0188
22/09/2015 11:14:22 | Dispense complete for COTTON, final dispense weight was 0.0292
22/09/2015 11:16:48 | Dispense complete for COTTON, final dispense weight was 0.0245
22/09/2015 11:18:37 | Dispense complete for COTTON, final dispense weight was 0.0243
22/09/2015 11:20:56 | Dispense complete for COTTON, final dispense weight was 0.0261
22/09/2015 11:22:53 | Dispense complete for COTTON, final dispense weight was 0.0228
22/09/2015 11:24:43 | Dispense complete for COTTON, final dispense weight was 0.0204
22/09/2015 11:26:38 | Dispense complete for COTTON, final dispense weight was 0.0223
22/09/2015 11:28:29 | Dispense complete for COTTON, final dispense weight was 0.0257
22/09/2015 11:30:20 | Dispense complete for COTTON, final dispense weight was 0.0371
22/09/2015 11:32:14 | Dispense complete for COTTON, final dispense weight was 0.0376
22/09/2015 11:36:18 | Dispense complete for COTTON, final dispense weight was 0.0222
22/09/2015 11:39:28 | Dispense complete for COTTON, final dispense weight was 0.0234
22/09/2015 11:41:23 | Dispense complete for COTTON, final dispense weight was 0.0255
22/09/2015 11:43:24 | Dispense complete for COTTON, final dispense weight was 0.0242
22/09/2015 11:46:30 | Dispense complete for COTTON, final dispense weight was 0.0354
22/09/2015 11:50:04 | Dispense complete for COTTON, final dispense weight was 0.0294";
// 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/