// 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"(?:[^ ]*\ ){2}([^ ]*)").unwrap();
let string = "04/04/19 11:54:10 7.4 78 3.9 2.1 0.0 63 0.00 0.00 1000.0 ENE 0 km/h C mb mm --- --- 0.20 167.00 --- 23.3 41 7.2 --- 7.4 11:49 2.4 5:18 9.7 11:15 9.7 11:15 1000.6 0:12 998.3 5:31 2.16 2.16 4.8 7.2 --- 1.0 0.01 311 --- 0.00 0 0 0 0 0 0 0 0 0 0 ";
// result will be a tuple containing the start and end indices for the first match in the string
let result = regex.captures(string);
let (start, end) = match result {
Some((s, e)) => (s, e),
None => {
// ...
}
};
println!("{}", &string[start, end]);
}
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/