// 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)(view_manage_opportunities),(view_page[^,]*)").unwrap();
let string = "DCA,customer1,company1,SID1,cherie,cherie,\"view_page_modulepicker,explore_more_connect with people\" DCA,customer2,company2,SID2,cherie,cherie,\"view_manage_opportunities,view_page_modulepicker,back_to_opp,view_page_modulepicker\" DCA,customer1,company1,SID1,cherie,cherie,\"view_manage_opportunities,view_page_modulepicker,explore_more_connect with people\" DCA,customer1,company1,SID1,cherie,cherie,\"view_page_modulepicker\" DCA,customer1,company1,SID1,cherie,cherie,\"view_manage_opportunities\" DCA,customer4,company1,SID4,cherie,cherie,\"view_manage_opportunities,view_page_actionSource\" DCA,customer4,company1,SID4,cherie,cherie,\"view_manage_opportunities,view_page_homePage\" DCA,customer4,company1,SID4,cherie,cherie,\"view_manage_opportunities,view_page_capabilities\"";
let substitution = "$2,$1";
// result will be a String with the substituted value
let result = regex.replace_all(string, substitution);
println!("{}", result);
}
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/