lark
lark copied to clipboard
Python 3.11: re.error: global flags not at the start of the expression at position
Python 3.11 expect (?i) to be at begging of regex:
abc: /(?i)def/
But lark probably contcatenate several regexes. So it leads to
abc: /(?i)def|(?i)qwe/
Second (?i) flag to be not at the begging of regex. So it raises exception and fail
That's unfortunate!
I think the only solution is to raise an error for Python 3.11 and up.
It is strange: I cannot reproduce it anymore. Probably lark grammar was wrong
The Python documentation agrees with you: https://docs.python.org/3/library/re.html
Changed in version 3.11: This construction can only be used at the start of the expression.
So, it's strange that you can no longer reproduce it!