mg wrote: > python 3.4.3 > > import re > re.search('(ab){2}','abzzabab') > <_sre.SRE_Match object; span=(4, 8), match='abab'> > >>>> re.findall('(ab){2}','abzzabab') > ['ab'] > > Why for search() the match is 'abab' and for findall the match is 'ab'?
I suppose someone thought it was convenient for findall to return the explicit groups if there are any. If you want the whole match aka group(0) you can get that with >>> re.findall('(?:ab){2}','abzzabab') ['abab'] -- https://mail.python.org/mailman/listinfo/python-list