// 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)\.populate_tasks\[(arc|buck|build|hg|phabricator|source_control),").unwrap();
let string = "── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[arc,diff]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[arc,fix]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[arc,focus]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[arc,lint]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[arc,pull]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[arc,refocus]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[buck,build]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[buck,install]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[buck,project]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[buck,run]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[buck,test]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[build,arc_rebuild]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[build,buck_build]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[build,entschema]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[build,fbios_noextensions]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[build,instagram_ios_noextensions]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[build,messenger_ios_noextensions]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[build,multifeed]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[build,unicorn]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[build,wakizashi]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[build,wakizashi_s2p]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[devserver,arc_fix]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[devserver,fixmyserver]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[devserver,flow_oom]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[devserver,hack_oom]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[devserver,hhserver_oom]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[hack,hh_healthy_minutes]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[hg,amend]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[hg,bookmarks]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[hg,branch]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[hg,commit]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[hg,diff]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[hg,log]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[hg,pull]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[hg,rebase]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[hg,smartlog]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[hg,status]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[hg,update]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[ide,flow_check]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[ide,flow_init]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[ide,hh_full_check]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[ide,hh_lazy_check]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[ide,hh_server_init]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[ide,intellij_file_to_intellisense]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[ide,intellij_project_to_intellisense]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[land,clean_lands]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[land,landcastle]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[phabricator,diffusion_pageload]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[phabricator,gql_client_duration]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[phabricator,gql_mutation_duration]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[phabricator,jf_submit_set_dependencies]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[phabricator,jf_submit_set_diffproperty]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[phabricator,jf_submit_total_elapsed]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[phabricator,jf_submit_update_diff]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[phabricator,jf_submit_update_revision]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[presto,adhoc_queue]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[source_control,hg]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[source_control,jellyfish]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[test,local_www]
── infrastructure.devspeed.error_rates.devspeed_raw_cost_events.populate_tasks[test,mobilelab]";
// 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/