- Captures
- captures_iter
Regex capture all the numbers - multiple match
examples/regex/regex-capture-multiple-numbers/src/main.rs
use regex::Regex; fn main() { let text = "There is the number 23 and another number here: 19"; println!("{}", text); let re = Regex::new(r"[0-9]+").unwrap(); let mut results = vec![]; for capture in re.captures_iter(text) { println!("{}", &capture[0]); results.push(capture[0].to_owned()); } println!("{:?}", results); }
There is the number 23 and another number here: 19 23 19 ["23", "19"]