// 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"(?<=twitch.tv\s)\w+(?=\s#)").unwrap();
let string = "@badges=moderator/1,premium/1;color=#00FF80;display-name=gempir;emotes=;id=d0358df2-f0a1-4600-910e-515ec52b1baa;mod=1;room-id=99659894;sent-ts=1489250823035;subscriber=0;tmi-sent-ts=1489250823211;turbo=0;user-id=77829817;user-type=mod :gempir!gempir@gempir.tmi.twitch.tv PRIVMSG #gempbot :!status
@ban-duration=20;ban-reason=Banned\\slink;room-id=11148817;target-user-id=78424343 :tmi.twitch.tv CLEARCHAT";
// 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/