lark icon indicating copy to clipboard operation
lark copied to clipboard

Python 3.11: re.error: global flags not at the start of the expression at position

Open xor2003 opened this issue 1 year ago • 3 comments

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

xor2003 avatar Oct 29 '22 18:10 xor2003

That's unfortunate!

I think the only solution is to raise an error for Python 3.11 and up.

erezsh avatar Nov 27 '22 13:11 erezsh

It is strange: I cannot reproduce it anymore. Probably lark grammar was wrong

xor2003 avatar Dec 01 '22 08:12 xor2003

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!

erezsh avatar Dec 01 '22 11:12 erezsh