[New-bugs-announce] [issue44940] Hint the use of non-capturing group in re.findall() documentation

Rondevous report at bugs.python.org
Tue Aug 17 18:24:06 EDT 2021


New submission from Rondevous <rondevu.mister at protonmail.com>:

Can it please be hinted in the docs of re.findall to use (?:...) for non-capturing groups?

>>> re.findall('(foo)?bar|cool', 'cool')
['']
>>>
### I expected the result: ['cool']

After hours of frustration, I learnt that I should use a non-capturing group (?:foo) in the pattern. This was not obvious.


P.S. Making the groups non-capturing in such a pattern is not needed in javascript (as tested on regexr.com); could this be an issue with the | operator in re.findall?

----------
assignee: docs at python
components: Documentation
messages: 399799
nosy: docs at python, rondevous
priority: normal
severity: normal
status: open
title: Hint the use of non-capturing group in re.findall() documentation
type: enhancement
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44940>
_______________________________________


More information about the New-bugs-announce mailing list