正则表达式可以导出RPN(逆波兰表示法)或后缀表示法吗

发布于 2024-12-25 21:42:05 字数 128 浏览 1 评论 0原文

我想知道是否可以定义一个正则表达式来检查给定的输入是否与 RPN 表达式匹配,即给定的输入是否有效?

不幸的是,我对正则表达式不是很熟悉,所以我想知道是否可以定义一个正则表达式来验证后缀的输入。

非常感谢 塔兹

I was wondering if I can define a Regular Expression to check whether a given input matches the RPN expression , i.e. whether the given input is valuid or not?

I am not very familiar with Regex unfortunately, so I was wondering if it is possible to define a regular expression to validate the input for postfix.

Many thanks
Taz

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

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

发布评论

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

评论(1

惯饮孤独 2025-01-01 21:42:05

正式来说,不; RPN 需要上下文无关语法,而正则表达式无法表达该语法。但是,可以使用“正则表达式”包或库来实现此目的,因为它们可以包含正则表达式正式定义之外的功能。

Formally, no; RPN would require a context-free grammar, which regular expressions cannot express. However, it might be possible to do so with a "regular expression" package or library, since they can contain features that are outside of the formal definition of regular expressions.

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