use fancy_regex::Regex;
fn find_verbs(input: &str) -> Vec<String> {
// Define the regular expression pattern
let pattern_str = r"(?<!\\\\)\@([a-zA-Z_]+)\(([^\)]*)\)";
let pattern = Regex::new(pattern_str).unwrap();
// Use the `captures_iter` method to iterate over all matches
let matches: Vec<String> = pattern
.captures_iter(input)
.filter_map(|capture_result| {
let capture = capture_result.expect("Error in capturing");
// Extract arguments from the capture groups
let arg1 = capture.get(1).unwrap().unwrap();
let arg2 = capture.get(2).unwrap().unwrap();
// Create a string representation of the match
Some(format!("@verb({}, {})", arg1, arg2));
})
.collect();
//return matches;
}
fn main() {
let input_text = "This is a sample text with @verb(arg1, arg2) and @verb(arg3, arg4).";
let result = find_verbs(input_text);
println!("Matches: {:?}", result);
}