문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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)

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.

The second reduces to first. Do you agree that

 ab+

and

 a(b)+

and

 (ab)+

are semantically different?

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top