[−][src]Function combine::parser::regex::find
pub fn find<R, Input>(regex: R) -> Find<R, Input> where
R: Regex<Input::Range>,
Input: RangeStream,
Input::Range: Range,
This is supported on crate feature
regex
only.Matches regex
on the input by running find
on the input and returns the first match.
Consumes all input up until the end of the first match.
extern crate regex; extern crate combine; use regex::Regex; use combine::Parser; use combine::parser::regex::find; fn main() { let mut digits = find(Regex::new("^[0-9]+").unwrap()); assert_eq!(digits.parse("123 456 "), Ok(("123", " 456 "))); assert!( digits.parse("abc 123 456 ").is_err()); let mut digits2 = find(Regex::new("[0-9]+").unwrap()); assert_eq!(digits2.parse("123 456 "), Ok(("123", " 456 "))); assert_eq!(digits2.parse("abc 123 456 "), Ok(("123", " 456 "))); }