Function neure::re::regex::sep

source ·
pub fn sep<'a, C, S, P>(pat: P, sep: S, skip: bool) -> RegexSeparate<C, P, S>where
    P: Regex<C>,
    S: Regex<C>,
    C: Context<'a> + Match<C>,
Expand description

Match the P terminated by S, return the return value of P.

Example

    color_eyre::install()?;
    let comma = re::one(',');
    let digit = re::one_more('0'..='9');
    let digit = re::sep(digit, comma, true);
    let mut ctx = CharsCtx::new("123,456,789");

    assert_eq!(ctx.try_mat_t(&digit)?, vec![Span::new(0, 3), Span::new(4, 3), Span::new(8, 3)]);
    Ok(())