// 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)^[^.\n]*[^\/\n]*\.\K[^\/\n]+").unwrap();
let string = "https://www.example.org/
http://example.com/
ca.gov
http://blade.example.com/bikes/airplane.php
http://alarm.example.com/
smugmug.com
shop-pro.jp
https://example.org/
qq.com
pcworld.com
symantec.com
360.cn
http://example.com/?brother=bike
http://www.example.com/behavior/bead.php
army.mil
https://example.com/boy/bedroom.php
https://example.com/
https://www.example.com/brother?activity=believe
https://www.example.net/achiever/bottle.html
http://believe.example.com/bit?bait=base&bone=ball
aboutads.info
http://www.example.com/
http://www.example.edu/afternoon
livejournal.com
http://border.example.com/box/afterthought
oaic.gov.au
https://www.example.edu/base.php
house.gov
smh.com.au
http://www.example.edu/
https://www.example.org/
lycos.com
https://border.example.com/?bridge=basket&blood=animal
hibu.com
http://example.com/";
// 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/