In the description of re.findall there is such a line:
Return to list of strings.
I think that's why you didn't find it in seacrh - because the condition implies the intersection of matches (in the template you use grouping).
Try the finditer method instead of the re.findall :
import re pattern = re.compile(r'([aeiouy])\1{2}') text = 'hooooweee' for m in pattern.finditer(text): print(m)
Result:
<_sre.SRE_Match object; span=(1, 4), match='ooo'> <_sre.SRE_Match object; span=(6, 9), match='eee'>
Ps.
As for findall , simplified the regular findall bit so that only vowel sequences were searched for and it works as expected:
items = re.findall('[aeiouy]{3}', 'hooooweee') print(items) # ['ooo', 'eee']
Pps.
Another example, in which with 3 groups we seize each vowel in a sequence of three consecutive symbols.
And as we see findall in its result puts, what indicates in the group, in contrast to the search and finditer :
import re pattern = re.compile(r'([aeiouy])([aeiouy])([aeiouy])') text = 'hooooweie' m = pattern.search(text) print(m) # <_sre.SRE_Match object; span=(1, 4), match='ooo'> print(m.group(), m.group(1), m.group(2), m.group(3)) # ooo ooo items = pattern.findall(text) print(items) # [('o', 'o', 'o'), ('e', 'i', 'e')] for m in pattern.finditer(text): print(m.group(), m.group(1), m.group(2), m.group(3)) # ooo ooo # eie eie
so for the pattern '([aeiouy][aeiouy])([aeiouy])' returns [('oo', 'o'), ('ei', 'e')]
str,list, etc. - these are the names of the built-in functions of python - docs.python.org/3.6/library/functions.html :) - gil9redre.findall,re.search,re.finditer- everyone works this way). There is no intersection in the condition. See the correct explanation and examples of solutions to this problem in my answer . - Wiktor Stribiżew