正则表达式:数学方式与编程方式

发布于 2024-09-13 01:02:35 字数 100 浏览 3 评论 0原文

考虑以下正则表达式:

  1. 7+
  2. (7)+

非常熟悉数学正则表达式理论的人是否同意这两个正则表达式在语义上相同?

Consider the following regular expressions:

  1. 7+
  2. (7)+

Does anyone that is very familiar with regular expression theory in Mathematics agree that the two regular expressions are semantically the same?

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

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

发布评论

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

评论(5

画▽骨i 2024-09-20 01:02:35

以编程方式(如由语言的正则表达式引擎计算),它仅在 捕获组 由此产生。

除此之外,它们是相同的。它就像写作 ((7) + (1)) 而不是 7 + 1。它们评估是相同的。 (是的,从数学上来说,常规语言不会评估任何东西)

Programmatically (as in evaluated by the regular expression engine of a language) it only differs in the capturing groups resulting.

Other than that, they are the same. It is as writing ((7) + (1)) as opposed as 7 + 1. They evaluate to are the same. (Yeah, mathematically speaking, regular languages doesn't evaluate to anything)

坚持沉默 2024-09-20 01:02:35

是的,这两个正则表达式是相同的,因为它们都识别相同的语言。事实上,它们的写法并不相同,这只是一个符号问题。

Yes, those two regular expressions are the same because they both recognize the same language. The fact that they are not written identically is just a notational issue.

挽袖吟 2024-09-20 01:02:35

它们描述的是同一种语言吗?是的。对于试图解释该语言的人来说,它们意味着同样的事情吗?不,第二个告诉我我应该对 7 更感兴趣。

Do they describe the same language? Yes. Do they mean the same thing to someone trying to interpret the language? No. The second one tells me that I should be more interested in the 7s.

国粹 2024-09-20 01:02:35

第二个减少到第一个。您是否同意

 ab+

 a(b)+

以及

 (ab)+

在语义上不同?

The second reduces to first. Do you agree that

 ab+

and

 a(b)+

and

 (ab)+

are semantically different?

窗影残 2024-09-20 01:02:35

唯一的区别是括号将封闭的模式分配给一个组,以便您可以在评估后引用该小块。

The only difference is the parens assign the enclosed pattern to a group so you can reference that little piece after it's been evaluated.

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