[issue42448] re.findall have different match result against re.search or re.sub

2021-08-17 Thread Rondevous
Rondevous added the comment: I was frustrated for hours when I couldn't figure out why this won't match: >>> re.findall(r'(foo)?bar|cool', 'cool') Now I know, I have to make this change: (?:foo) But this isn't obvious. Should it be mentioned in

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

2021-08-17 Thread Rondevous
New submission from Rondevous : 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 fru

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

2021-08-20 Thread Rondevous
Rondevous added the comment: To clarify in short: the pattern I mentioned doesn't give the result I expected in re.findall() unlike re.search() Given pattern: (foo)?bar|cool Maybe my approach in testing the regex first using re.search() and then using re.findall() to return all ma

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

2021-08-20 Thread Rondevous
Rondevous added the comment: >From my understanding, "|" should match either the RegEx on the left or the >RegEx on the right of the pipe >>> help(re): "|" A|B, creates an RE that will match either A or B. With re.search(), the pattern b

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

2021-08-20 Thread Rondevous
Rondevous added the comment: Maybe the functionality of re.findall and re.finditer is limited because, e.g. I can't do something like this: https://stackoverflow.com/questions/3512471/what-is-a-non-capturing-group-in-regular-expressions#3513858 The workaround for doing that might need

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

2021-08-20 Thread Rondevous
Rondevous 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 capturin

[issue44940] Clarify the documentation of re.findall()

2021-08-21 Thread Rondevous
Rondevous added the comment: Oops, I was wrong about re.finditer :D Sorry, I think didn't check that properly. Just saw the changes. The patch looks good :) Thanks a lot! -- title: Suggest the use of non-capturing groups in re.findall() and re.finditer() docs -> Cla