// 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)(?<ipv6_full>(?:^(?:f[c-f][0-9a-f]{2}|200[1-2]|0?100):).+|(?:.+:0{0,3}1$|(?:.+:ffff:(?:0:)?|^0{0,2}64:ff9b::)(?<ipv4_map>(?:25[0-5]|2[0-4]\d|[0-1]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[0-1]?\d{1,2})){3})$))").unwrap();
let string = "::1
100::
2001::
2001:20::
2001:db8::
2002::
fc00::
fe80::
ff00::
64:ff9b::0.0.0.0
100::
::ffff:0.0.0.0
::ffff:0:255.255.255.255";
// 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/