Re: one more question on regex

2016-01-23 Thread Vlastimil Brom
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

Re: one more question on regex

2016-01-22 Thread mg
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(

Re: one more question on regex

2016-01-22 Thread Vlastimil Brom
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'

Re: one more question on regex

2016-01-22 Thread 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' and for findall the match is 'ab'? find

Re: one more question on regex

2016-01-22 Thread Peter Otten
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

one more question on regex

2016-01-22 Thread mg
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