Function nom::regexp::str::re_captures[][src]

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

Compares the input with a regular expression and returns the capture groups of all matches in a nested Vec.

Requires the regexp feature.

Example

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