// 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"magnet:\?((&?xt\.?\d*=urn:[A-Za-z0-9][A-Za-z0-9-]{0,31}:[A-Fa-f0-9]{20,50})|(&?(dn|tr|xl|ws|as|xs|kt|mt)=[A-Za-z0-9\-._%+;=:?\/]+)&?)+$").unwrap();
let string = "magnet:?xt=urn:btih:6B5FFA38E0C811E0738697BEC13DDDA57A60FCB4&dn=Taboo.UK.Season.1.S01.1080p.AMZN.WEBRip.5.1.HEVC.x265-GIRAYS&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2920%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&as=udp%3A%2F%2Ftracker.internetwarriors.net%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounc/e&tr=udp%3A%2F%2Ftracker.pirateparty.gr%3A6969%2Fannounce&tr=udp%3/A%2F%2Ftracker.cyberia.is%3A6969%2Fannounce&xt=urn:btih:6B5FFA38E0C811E0738697BEC13DDDA57A60FCB4&xt=urn:btih:6B5FFA38E0C811E0738697BEC13DDDA57A60FCB4&xs=dchub://example.org&as=http%3A%2F%2Fdownload.wikimedia.org%2Fmediawiki%2F1.15%2Fmediawiki-1.15.1.tar.gz&xl=10826029&dn=mediawiki-1.15.1.tar.gz";
// 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/