// 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"Hash:
0xcba5ee76d1b322114c4e5b1a3e00edf1065bf0346bef88ee603a8a061908db88https://img.shields.io/azure-devops/coverage/0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3/https://tokenview.com/en/search/0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684/974618121112?color=https%3A%2F%2Fimg.shields.io%2Fazure-devops%2Fcoverage%2F0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3%2Fhttps%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684%2F974618121112&label=%3Cimg%20alt%3D%22Azure%20DevOps%20coverage%22%20src%3D%22https%3A%2F%2Fimg.shields.io%2Fazure-devops%2Fcoverage%2F0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3%2Fhttps%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684%2F974618121112%22%3E&logo=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&logoColor=https%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684&style=plastic").unwrap();
let string = "https://img.shields.io/azure-devops/coverage/0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3/https://tokenview.com/en/search/0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684/974618121112?color=https%3A%2F%2Fimg.shields.io%2Fazure-devops%2Fcoverage%2F0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3%2Fhttps%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684%2F974618121112&label=%3Cimg%20alt%3D%22Azure%20DevOps%20coverage%22%20src%3D%22https%3A%2F%2Fimg.shields.io%2Fazure-devops%2Fcoverage%2F0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3%2Fhttps%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684%2F974618121112%22%3E&logo=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&logoColor=https%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684&style=plastic.. image:: https://img.shields.io/azure-devops/coverage/0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3/https://tokenview.com/en/search/0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684/974618121112?color=https%3A%2F%2Fimg.shields.io%2Fazure-devops%2Fcoverage%2F0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3%2Fhttps%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684%2F974618121112&label=%3Cimg%20alt%3D%22Azure%20DevOps%20coverage%22%20src%3D%22https%3A%2F%2Fimg.shields.io%2Fazure-devops%2Fcoverage%2F0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3%2Fhttps%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684%2F974618121112%22%3E&logo=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&logoColor=https%3A%2F%2Ftokenview.com%2Fen%2Fsearch%2F0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684&style=plastic :alt: Azure DevOps coverage<img alt=\"Azure DevOps coverage\" src=\"https://img.shields.io/azure-devops/coverage/0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3/https://tokenview.com/en/search/0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684/974618121112\">https://img.shields.io/azure-devops/coverage/0xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3/https://tokenview.com/en/search/0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f19684/974618121112https://tokenview.com/en/search/0xdf6ac64b05e8bb7ca5c8d31ff44a00544eb039a7f467a424ae1c1e1926f196840xb95343413e459a0f97461812111254163ae53467855c0d73e0f1e7c5b8442fa3";
// 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/