[issue44940] Suggest the use of non-capturing groups in re.findall() and re.finditer() docs

Rondevous report at bugs.python.org
Fri Aug 20 12:02:49 EDT 2021


Rondevous <rondevu.mister at protonmail.com> added the comment:

To produce the same results that you'd get by using the global flag in javascript regex, and make re.findall to not capture the groups exclusively, all the groups in the pattern need to be of the non-capturing (?:) type. 

If the distinction about capturing and non-capturing groups is mentioned in the docs of re.findall, it would help those who have learnt regex from another language (like javascript), where the global flag in regex is allowed.

I want the docs of re.findall and re.finditer to somehow suggest the use (?:group) to return the original matches and not the captured groups.

----------

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


More information about the Python-bugs-list mailing list