pub fn captures<'h, Input, Re, Error>(
re: Re,
) -> CapturesParser<'h, Input, Re::Output, Error>where
Input: StreamIsPartial + Stream + Offset + Clone,
Re: RegexPattern,
Re::Output: Regex,
Re::Error: Debug,
Error: ParserError<Input> + 'static,
Expand description
ยงExample
use winnow::prelude::*;
use winnow_regex::{captures, Captures};
fn digits<'i>(s: &mut &'i str) -> ModalResult<(i32, i32)> {
captures(r"^(\d+)x(\d+)").map(|c: Captures<&str, _>| (c[1].parse().unwrap(), c[2].parse().unwrap())).parse_next(s)
}
assert_eq!(digits.parse_peek("11x42abc"), Ok(("abc", (11, 42))));