// 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+)\s?°\s?(\d+)\s?'\s?(\d+\.?\,?\d*?)"\s?(N|W|S|E)"#).unwrap();
let string = "15° 1' 36.991\" E
15° 2' 21.421\" E
15° 2' 0.712\" E
15° 2' 45.181\" E
15° 3' 1.709\" E
14° 58' 24.822\" E
14° 58' 39.840\" E
14° 58' 26.234\" E
14° 58' 45.145\" E
15° 0' 14.01\" E
15° 0' 11.460\" E
15° 0' 7.928\" E
15° 1' 53.693\" S
15° 2' 24.699\" E
15° 2' 45.547\" E
15° 2' 12.837\" E
15° 2' 43.594\" E
15° 2' 31.644\" E
15° 3' 1.059\" E
14° 59' 46.315\" E
14° 59' 31.694\" E
15° 2' 41.057\" E
14° 58' 40.068\" E
36°57'9\" N";
// 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/