expression
Regex::find: first matching span
Find the first match and its byte range, or None. The returned match borrows the original text. This example uses the external regex crate; see the staged Cargo manifest. Expected stdout (not executed): 42 3..5 Common mistake: Treating end as an inclusive offset.
Formal Syntax & Structure
rust syntaxrust
re.find(text) -> Option<Match>Working Example
Example Snippetrust
fn main() { let re = regex::Regex::new(r"[0-9]+").unwrap(); let m = re.find("id=42; next=8").unwrap(); println!("{} {}..{}", m.as_str(), m.start(), m.end());}