Function neure::re::regex::quote

source ·
pub fn quote<'a, C, L, R, P>(
    pat: P,
    left: L,
    right: R
) -> RegexQuote<C, P, L, R>where
    P: Regex<C>,
    L: Regex<C>,
    R: Regex<C>,
    C: Context<'a> + Match<C>,
Expand description

Match the P enclosed by L and R.

Example

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

    assert_eq!(
        ctx.try_mat_t(&array)?,
        vec![Span::new(1, 3), Span::new(5, 3), Span::new(9, 3)]
    );
    Ok(())