Bug report
Bug description:
For some reason declaring a capture group inside a non-capturing group causes the non-capturing group to capture its content. Either the documentation doesn't explain the non-capturing group behavior correctly or this is a bug.
Note: The example here doesn't need the non-capturing group but I use it in a longer > regex. This is the minimal setup for reproducing the behavior I'm encountering.
import re
match = re.match(r'(:?test[(]([^)]*)[)])', "test(abc)")
print(match)
Result:
Expected result:
CPython versions tested on:
3.13, 3.12
Operating systems tested on:
Linux