// 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"([\:][\/]{0,2})[\w\-]+([\@]|[\.])?([\w\-]+[\.]){0,}([\w\-]+)?([\:][\d]+)?[\/]?").unwrap();
let string = "https://user_test-teste@regex101.com:80/
http://localhost:80/
https://tools.ietf.org/html/rfc3986#page-7
https://translate.google.com.br/#en/pt/that%20what
https://www.google.com.br/search?client=firefox-b&biw=1920&bih=1001&q=overload+inexistent+property+php&oq=overload+inexistent+property+php&gs_l=psy-ab.3..33i22i29i30k1.36919.57166.0.57324.38.36.2.0.0.0.682.3958.14j18j5-1.33.0....0...1.1.64.psy-ab..3.27.3324...0j35i39k1j0i131k1j0i67k1j0i10k1j0i22i30k1j33i160k1j33i21k1.m5dBRh4nQ-I";
// 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/