This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rondevous
Recipients docs@python, rondevous
Date 2021-08-17.22:24:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1629239046.75.0.423461536015.issue44940@roundup.psfhosted.org>
In-reply-to
Content
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?
History
Date User Action Args
2021-08-17 22:24:06rondevoussetrecipients: + rondevous, docs@python
2021-08-17 22:24:06rondevoussetmessageid: <1629239046.75.0.423461536015.issue44940@roundup.psfhosted.org>
2021-08-17 22:24:06rondevouslinkissue44940 messages
2021-08-17 22:24:06rondevouscreate