pub fn count_if<'a, const M: usize, const N: usize, C, U, F>(
re: U,
if: F
) -> NeureRepeat<M, N, C, U, F>where
C: Context<'a> + 'a,
U: Neu<C::Item>,
F: NeuCond<'a, C>,Expand description
Match the given Neu M ..= N times.
Example
let website = re::count_if::<0, { usize::MAX }, _, _, _>(
('a'..'{').or('.'),
|ctx: &CharsCtx, pair: &(usize, char)| {
Ok(pair.1 != '.'
|| ctx
.orig()?
.get((pair.0 + 1)..)
.map(|v| v.find('.').is_some())
.unwrap_or(false))
},
);
let mut ctx = CharsCtx::new("domain.example.com");
assert_eq!(ctx.try_mat(&website)?, Span::new(0, 14));
assert_eq!(ctx.orig_sub(0, 14)?, "domain.example");
Ok(())
}