use regex::Regex;
fn main() {
let str_value = r#"This is a string with "double-quoted substring1", and "double-quoted substring2" inside."#;
// Regular expression pattern to match substrings within double quotes
let pattern = Regex::new(r#""([^"]*)""#).unwrap();
// Find all matches
let matches: Vec<String> = pattern
.captures_iter(str_value)
.map(|cap| cap[1].to_string())
.collect();
println!("{:?}", matches);
for m in matches {
println!("{}", &m); // Print each matched substring
}
}
/*
run:
["double-quoted substring1", "double-quoted substring2"]
double-quoted substring1
double-quoted substring2
*/