如何在树顶钉中定义 {min,max} 匹配

发布于 2024-08-06 11:48:55 字数 156 浏览 2 评论 0原文

使用 Ruby 的正则表达式,我可以编写 /[0-9]{3,}/ 除了:树顶

rule at_least_three_digit_number
  [0-9] [0-9] [0-9]+
end

是否有“匹配[至少|最] n”规则?

With Ruby's regular expressions I could write /[0-9]{3,}/ I can't figure out how to write this in treetop other than:

rule at_least_three_digit_number
  [0-9] [0-9] [0-9]+
end

Is there a 'match [at least|most] n' rule for treetop?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

治碍 2024-08-13 11:48:55

看起来 PEG 没有一些 RE 便利运算符,但作为回报,您确实获得了更强大的表达式匹配器。

It looks like PEGs don't have some of the RE convenience operators, but in return you do get a much more powerful expression matcher.

勿忘初心 2024-08-13 11:48:55

还提供通用重复计数(最小、最大)。

'foo' 2.. 匹配 'foo' 两次或多次

'foo' 3..5 匹配 'foo' 三到五次

'foo' ..4 与 'foo' 匹配零到四次

http://treetop.rubyforge.org/syntactic_recognition.html

A generalised repetition count (minimum, maximum) is also available.

'foo' 2.. matches 'foo' two or more times

'foo' 3..5 matches 'foo' from three to five times

'foo' ..4 matches 'foo' from zero to four times

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文