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

pub fn re_capture<'a, E>(
    re: Regex
) -> impl Fn(&'a str) -> IResult<&'a str, Vec<&'a str>, E> where
    E: ParseError<&'a str>, 

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::Regex::new(r"(a)(\d)").unwrap();
let parser = re_capture::<(&str, ErrorKind)>(re);
assert_eq!(parser("a1ba2"), Ok(("ba2", vec!["a1", "a", "1"])));
assert_eq!(parser("abc"), Err(Err::Error(("abc", ErrorKind::RegexpCapture))));