Function nom::regexp::bytes::re_find[][src]

pub fn re_find<'a, E>(
    re: Regex
) -> impl Fn(&'a [u8]) -> IResult<&'a [u8], &'a [u8], E> where
    E: ParseError<&'a [u8]>, 
This is supported on crate feature regexp only.

Compares the input with a regular expression and returns the first match.

Requires the regexp feature.

Example

let re = regex::bytes::Regex::new(r"\d{4}").unwrap();
let parser = re_find::<(&[u8], ErrorKind)>(re);
assert_eq!(parser(&b"abc2019"[..]), Ok((&b""[..], &b"2019"[..])));
assert_eq!(parser(&b"abc"[..]), Err(Err::Error((&b"abc"[..], ErrorKind::RegexpFind))));
assert_eq!(parser(&b"2019-10"[..]), Ok((&b"-10"[..], &b"2019"[..])));