When I was using regular expressions in my program, I found some unusual behavior.
For example, I can write this:
Python 3.9.0 (default, Nov 18 2020, 13:28:38)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyformlang.regular_expression import Regex
>>> Regex('a a | a')
((a.a)|a)
>>> Regex('a . a | a')
((a.a)|a)
>>> Regex('a* a | a')
(((a)*.a)|a)
So, I realise that priority of operator . more than priority of operator |. But when I use * just before |, priority of this operations changes:
Hello,
When I was using regular expressions in my program, I found some unusual behavior.
For example, I can write this:
So, I realise that priority of operator
.
more than priority of operator|
. But when I use*
just before|
, priority of this operations changes:I can define expression
((a.(a)*)|a)
only through using parenthesis:And error isn't in printing: