如何为nom
创建一个负向超前解析器?
例如,我想要解析"Hello",除非后面跟"world".等同的正则表达式将是hello(?! world)
.
我try 将cond
、not
和peek
解析器组合在一起
fn parser(input: &str) -> IResult<&str, &str> {
cond(peek(not(tag(" world"))(input)), tag("hello"))(input)
}
但这并不像cond
预期的那样,条件是bool
而不是IResult
.