// 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)\|poke\|p([1,2])\|(.+?)(,|\|)").unwrap();
let string = "|poke|p1|Volcarona, M|
|poke|p1|Urshifu-*, F|
|poke|p1|Magnezone|
|poke|p1|Tangrowth, M|
|poke|p1|Corviknight, F|
|poke|p1|Hippowdon, F|
|poke|p2|Togekiss, M|
|poke|p2|Kommo-o, M|
|poke|p2|Jirachi|
|poke|p2|Mimikyu, F|
|poke|p2|Dragalge, F|
|poke|p1|Dragapult, F|
|poke|p1|Hatterene, F|
|poke|p1|Flygon, F|
|poke|p1|Inteleon, F|
|poke|p1|Obstagoon, F|
|poke|p1|Arcanine, F|
|poke|p2|Pincurchin, F|
|poke|p2|Magnezone|
|poke|p2|Hawlucha, F|
|poke|p2|Raichu-Alola, M|
|poke|p2|Ferrothorn, M|
|poke|p2|Magearna-Original|
|poke|p1|Slowbro, M|
|poke|p1|Tangrowth, F|
|poke|p1|Crawdaunt, F|
|poke|p1|Dragapult, M|
|poke|p1|Clefable, M|
|poke|p1|Excadrill, M|
|poke|p2|Togekiss, F|
|poke|p2|Starmie|
|poke|p2|Urshifu-*, M|
|poke|p2|Amoonguss, M|
|poke|p2|Cinderace, F|
|poke|p2|Jirachi|";
// 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/