// 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"((?:(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(?-1))").unwrap();
let string = "Feb 8 21:48:20 server dhcpd: DHCPREQUEST for 10.232.10.241 (10.232.10.241) from 24:77:03:18:c9:d4 (kimxlt-03) via eth1
Feb 8 21:48:20 server dhcpd: DHCPACK on 10.232.10.76 to 24:77:03:18:c9:d4 (kimxlt-03) via eth1
Feb 8 21:48:24 server dhcpd: DHCPINFORM from 10.232.10.76 via eth1
Feb 8 21:48:24 server dhcpd: DHCPACK to 10.232.10.76 (24:77:03:18:c9:d4) via eth1
Feb 8 21:50:31 server dhcpd: DHCPINFORM from 10.232.10.92 via eth18 21:50:31 server dhcpd: DHCPACK to 10.232.10.92 (00:1c:c0:58:85:1b) via eth1
Feb 8 21:55:44 server dhcpd: DHCPINFORM from 10.232.10.92 via eth1
Feb 8 21:55:44 server dhcpd: DHCPACK to 10.232.10.92 (00:1c:c0:58:85:1b) via eth1
";
// 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/