Function at_most

Source
pub fn at_most<P>(n: usize, pattern: P) -> Repetition<P>
where P: Pattern,
Expand description

Returns a new pattern that matches at most n repetitions of pattern.

use bparse::{Pattern, at_most};

assert_eq!(at_most(2, "b").eval(b"b"), Some(1));
assert_eq!(at_most(2, "b").eval(b"bbbb"), Some(2));
assert_eq!(at_most(2, "b").eval(b"aa"), Some(0));