// 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)^[0-9]{1,3}.[0-9]{1,3}").unwrap();
let string = "103.145.72.0/24 Alibaba.com HK(Kaopuyun) 256
110.76.21.0/24 Zhejiang Ant Small And Micro Financial Services 256
122.254.76.0/23 Internet Global (group) Co., LTD 512
116.251.120.0/22 Zhejiang Taobao Network Co.,Ltd 1,024
149.129.16.0/23 Alibaba.com Singapore E-Commerce Private Limited 512
8.209.96.0/19 Westendstrabe 28, 60325 Frankfurt am Main 8,192";
// 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/