// 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)P1127_VELOCITIES #001000 Step: (\d+) Iteration: (\d+) Time: (\d+\.\d+) {1,2}(\d*\.\d+|-\d*\.\d+)").unwrap();
let string = "Number of zero columns: 4
Memory requirement - global matrix: 1571340 solver (totally): 1571340
P1127_VELOCITIES #001000 Step: 59 Iteration: 2 Time: 0.04055 0.0015347
P2243_VELOCITIES #001000 Step: 59 Iteration: 2 Time: 0.04055 0.0017193
P3387_VELOCITIES #001000 Step: 59 Iteration: 2 Time: 0.04055 0.0015347
% of load in interval Step: 59 Iteration: 2 Time: 0.04055 0.0400000 0.0400000
summation % of load in interval Step: 59 Iteration: 2 Time: 0.04055 0.0800000
Number of zero columns: 4
Memory requirement - global matrix: 1571340 solver (totally): 1571340
P1127_VELOCITIES #001000 Step: 59 Iteration: 2 Time: 0.01638 -0.0016876
P2243_VELOCITIES #001000 Step: 59 Iteration: 2 Time: 0.01638 -0.0018896
P3387_VELOCITIES #001000 Step: 59 Iteration: 2 Time: 0.01638 -0.0016876
% of load in interval Step: 59 Iteration: 2 Time: 0.01638 0.0400000 0.0400000
summation % of load in interval Step: 59 Iteration: 2 Time: 0.01638 0.0800000 ";
// 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/