.findall() gets unexpected result with capture-group

Create issue
Issue #209 invalid
animalize created an issue

*Edit, this case is simpler:

>>> regex.findall(r'(A)a', 'Aa')
['A']
>>> regex.findall(r'(?r)(A)a', 'Aa')
['A']

Old cases:

# (?i), expected result: ['CcdogcC']
>>> regex.findall(r'(?i)..(?<=(\L<aa>))dog\1', 'CcdogcC', aa=['bcb', 'cc'])
['Cc']

# (?ri), expected result: ['CcdogcC']
>>> regex.findall(r'(?ri)\1dog(?=(\L<aa>))..', 'CcdogcC', aa=['bcb', 'cc'])
['cC']

Test on regex 2016.05.15.

Comments (5)

  1. Matthew Barnett repo owner

    For future reference:

    As per the docs, the regex contains a capture group, so that's what .findall returns. It would return the entire match only if there were no capture groups.

  2. Log in to comment