// 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)([[:space:]]+|^)areaIntegrate\(down\) of grad\(T\)y[[:space:]]+").unwrap();
let string = "
Time = 0
Reading fields:
volScalarField: grad(T)y
Executing functionObjects
surfaceFieldValue patchIntegrate(name=down,grad(T)y) write:
total faces = 4000
total area = 5.286456431623655e-06
areaIntegrate(down) of grad(T)y = -0.3799414476287353
Space-averaged Nusselt lambda = 5.34607670341618
Time = 0.45
Reading fields:
volScalarField: grad(T)y
Executing functionObjects
surfaceFieldValue patchIntegrate(name=down,grad(T)y) write:
areaIntegrate(down) of grad(T)y = -0.6680860499604798
Space-averaged Nusselt lambda = 5.34607670341618";
// 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/