one more question on regex

mg noOne at nowhere.com
Fri Jan 22 10:32:57 EST 2016


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'? 



More information about the Python-list mailing list