firasdib / Regex101

This repository is currently only used for issue tracking for www.regex101.com
3.2k stars 198 forks source link

"Incomplete group structure" but Python has no problem with it #2218

Open buhtz opened 5 months ago

buhtz commented 5 months ago

I get the error "Incomplete group structure" when I use the following pattern ("Python") on regex101.com.

^#\+(?i:begin)_(\S+)(?:\s(.+))?

But using this pattern with Python 3.11.2 it works as expected without errors. So what could it be?

This is the link: https://regex101.com/r/s63H0w/1

This is how it looks in Python.

Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> rex = re.compile(r'^#\+(?i:begin)_(\S+)(?:\s(.+))?')
>>> rex.match('#+begin_src python')
<re.Match object; span=(0, 18), match='#+begin_src python'>
>>> rex.match('#+begin_src python').groups()
('src', 'python')
buhtz commented 5 months ago

Might be related to #1698 ?

If it is because Python version 2 is in the back then I would suggest to rename "Python" to "Python 2" in the flavor menu.

firasdib commented 5 months ago

Yes, the python implementation on regex101 is very outdated, it is python 2.7... I should update the name, as you suggested, until a more recent version can be implemented.

mangelozzi commented 2 months ago

Hitting the same problem trying to debug a Django regex. Python 2 is deprecated, that is critical information when trying to debug a problem. Need to debug the debug tool =)