Message399799
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? |
|
Date |
User |
Action |
Args |
2021-08-17 22:24:06 | rondevous | set | recipients:
+ rondevous, docs@python |
2021-08-17 22:24:06 | rondevous | set | messageid: <1629239046.75.0.423461536015.issue44940@roundup.psfhosted.org> |
2021-08-17 22:24:06 | rondevous | link | issue44940 messages |
2021-08-17 22:24:06 | rondevous | create | |
|