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

pub fn re_match<'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 whole input if a match is found.

Requires the regexp feature.

Example

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