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

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

Compares the input with a regular expression and returns the capture groups of the first match in a Vec.

Requires the regexp feature.

Example

let re = regex::bytes::Regex::new(r"(a)(\d)").unwrap();
let parser = re_capture::<(&[u8], ErrorKind)>(re);
assert_eq!(parser(&b"a1ba2"[..]), Ok((&b"ba2"[..], vec![&b"a1"[..], &b"a"[..], &b"1"[..]])));
assert_eq!(parser(&b"abc"[..]), Err(Err::Error((&b"abc"[..], ErrorKind::RegexpCapture))));