expression
Regex::find_iter: nonoverlapping matches
Iterate matching spans from left to right. Ordinary iteration does not enumerate every overlapping match. This example uses the external regex crate; see the staged Cargo manifest. Expected stdout (not executed): [1..4] Common mistake: Expecting overlapping occurrences at both offsets in banana.
Formal Syntax & Structure
rust syntaxrust
re.find_iter(text)Working Example
Example Snippetrust
fn main() { let re = regex::Regex::new("ana").unwrap(); let spans: Vec<_> = re.find_iter("banana").map(|m| m.range()).collect(); println!("{:?}", spans);}