Function neure::neu::re_cond

source ·
pub fn re_cond<'a, C, T>(regex: T) -> RegexCond<'a, C, T>
Expand description

Create a condition using in Condition base on regex.

Example

     let escape = b'\\'.then(b'"');
     let str = neu::not(b'"')
         .repeat_one_more()
         // avoid match escape sequence
         .set_cond(neu::re_cond(re::not(escape)))
         // match the escape sequence in another regex
         .or(escape)
         .repeat(1..)
         .pat();
     let mut ctx = BytesCtx::new(br#""Hello world from \"rust\"!""#);

     assert_eq!(ctx.try_mat(&str.quote(b"\"", b"\""))?, Span::new(0, 28));
     Ok(())