// 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"(?i)^(-|Un reportaje de|Por)").unwrap();
let string = "por This is an example text, this text contains emails, phone numbers and other sample designed for testing purposes. To use this tool, please type a regular expression in the text-area above.
When designing regex for emails make sure you cover all possible email types like: info@breatheco.de, dragon23@gmail.com, dragon_ball@yahoo.com.us and also test for bad email formats like ramond=32@skas.com
When texting for urls you have samples like this: https://thedomain.com.ve/dir1/dir2.html, some urls don't have extensions like this http://www.thedomain.net/directory1, maybe you will find some urls with nested subdomains like http://test.www.thedomain.com.ve/directory1";
// result will be a tuple containing the start and end indices for the first match in the string
let result = regex.captures(string);
let (start, end) = match result {
Some((s, e)) => (s, e),
None => {
// ...
}
};
println!("{}", &string[start, end]);
}
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/