// 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)10\.(?:[0-9]|[0-1][0-9]?|20)\.0\.(?:25[0-4]|2[0-4][0-9]|1[0-9][0-9]|[2-9][0-9]|1[1-9]|[1-9])").unwrap();
let string = "10.0.0.1
10.19.0.13
10.22.0.13
10.20.0.2
10.0.0.6
10.24.0.1
10.19.0.233
10.18.0.13
10.17.0.12
10.0.0.12
10.0.0.211
10.3.0.123
10.4.0.121
10.5.0.200
10.5.0.201
10.5.0.1
10.4.0.0
10.4.0.254
10.0.0.12
10.9.0.134
10.10.0.112
10.20.0.254
10.20.0.1
10.20.0.9
10.19.0.19
10.18.0.18
10.13.0.1
";
// 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/