pub fn re_matches<'a, E>(
re: Regex,
) -> impl Fn(&'a [u8]) -> IResult<&'a [u8], Vec<&'a [u8]>, E>where
E: ParseError<&'a [u8]>,
Expand description
Compares the input with a regular expression and returns all matches in a Vec
.
Requires the regexp
feature.
ยงExample
let re = regex::bytes::Regex::new(r"a\d").unwrap();
let parser = re_matches::<(&[u8], ErrorKind)>(re);
assert_eq!(parser(&b"a1ba2"[..]), Ok((&b""[..], vec![&b"a1"[..], &b"a2"[..]])));
assert_eq!(parser(&b"abc"[..]), Err(Err::Error((&b"abc"[..], ErrorKind::RegexpMatches))));