2016-01-22 23:47 GMT+01:00 mg :
> Il Fri, 22 Jan 2016 21:10:44 +0100, Vlastimil Brom ha scritto:
>
>> [...]
>
> You explanation of re.findall() results is correct. My point is that the
> documentation states:
>
> re.findall(pattern, string, flags=0)
> Return all non-overlapping matches of patte
Il Fri, 22 Jan 2016 21:10:44 +0100, Vlastimil Brom ha scritto:
> 2016-01-22 16:50 GMT+01:00 mg :
>> Il Fri, 22 Jan 2016 15:32:57 +, mg ha scritto:
>>
>>> python 3.4.3
>>>
>>> import re re.search('(ab){2}','abzzabab')
>>> <_sre.SRE_Match object; span=(4, 8), match='abab'>
>>>
>> re.findall(
2016-01-22 16:50 GMT+01:00 mg :
> Il Fri, 22 Jan 2016 15:32:57 +, mg ha scritto:
>
>> 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'
Il Fri, 22 Jan 2016 15:32:57 +, mg ha scritto:
> 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'?
find
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
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'?
--
https://mail.python.org/mailman/listinfo/python-list