// 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)^Maximum amplitude:\s*(-?\d\.\d+)\n").unwrap();
let string = "Samples read: 6615000
Length (seconds): 75.000000
Scaled by: 2147483647.0
Maximum amplitude: 0.712219
Minimum amplitude: -0.805969
Midline amplitude: -0.046875
Mean norm: 0.009264
Mean amplitude: -0.000027
RMS amplitude: 0.043011
Maximum delta: 0.734100
Minimum delta: 0.000000
Mean delta: 0.008353
RMS delta: 0.041470
Rough frequency: 6767
Volume adjustment: 1.241";
// 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/