// 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"(?m)^@[^=]*?=(?<badgeinfo>.*?);[^=]*?=(?<badges>.*?);c[^=]*?=(?<clientNonce>.*?);[^=]*?=(?<color>.*?);[^=]*?=(?<name>.*?);[^=]*?=(?<emojis>.*?);[^=]*?=(?<firstMsg>.*?);[^=]*?=(?<flags>.*?);[^=]*?=(?<id>.*?);[^=]*?=(?<mod>.*?);[^=]*?=(?<returningChatter>.*?)[^=]*?=(?<roomId>.*?);[^=]*?=(?<sub>.*?);[^=]*?=(?<tmi>.*?);[^=]*?=(?<turbo>.*?);[^=]*?=(?<userId>.*?);[^=]*?=(?<userType>.*?):[^=]*? :(?<message>.*)").unwrap();
let string = "@badge-info=;badges=broadcaster/1,premium/1;client-nonce=8f8a16f3582a7b95bc270350fe1a635d;color=#D2691E;display-name=buckybubba;emotes=;first-msg=0;flags=;id=26e18d04-2e0d-41d9-a8e9-925a434d7142;mod=0;returning-chatter=0;room-id=460209762;subscriber=0;tmi-sent-ts=1690833107242;turbo=0;user-id=460209762;user-type= :buckybubba!buckybubba@buckybubba.tmi.twitch.tv PRIVMSG #buckybubba :Test";
// 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/