问题描述
我已经阅读了 nom
6.2.1 的 the documentation,我正在尝试构建一个解析器,该解析器将匹配任意数量的字符(包括零)后跟单词 foobar:{ {1}}。
/.*foobar/
几乎可以做我想做的事,但它不会消耗 nom::bytes::complete::take_until("foobar")
本身,所以我不得不这样做:
foobar
我倾向于考虑传统的正则表达式语法,然后必须将其映射到 use nom::bytes::complete::{tag,take_until};
use nom::combinator::value;
use nom::sequence::tuple;
use nom::IResult;
// This method does what I want,but is verbose because foobar is repeated
fn arbitrary_and_then_foobar(s: &str) -> IResult<&str,()> {
value((),tuple((take_until("foobar"),tag("foobar"))))(s)
}
提供的可用结构。我越来越善于注意到 nom
构造更适合的场景,但是否有正则表达式到nom 备忘单?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)