On 2/11/2010 12:19 PM, Yingjie Lan wrote:
From: John Bond
Subject: Re: Why this result with the re module
Firstly, thanks a lot for your patient explanation.
this time I have understood all your points perfectly.
Secondly, I'd like to clarify some of my points, which
did not get th
> From: Vlastimil Brom
> Subject: Re: Why this result with the re module
> in that case you may use re.finditer(...)
Thanks for pointing this out.
Still I'd love to see re.findall never
discards the whole match, even if
a tuple is returned.
Yingjie
--
http://m
2010/11/2 Yingjie Lan :
>> From: John Bond
>> Subject: Re: Why this result with the re module
> ...
> I suggested findall return a tuple of re.MatchObject(s),
> with each MatchObject instance representing a match.
> This is consistent with the re.match() function anyway.
> From: John Bond
> Subject: Re: Why this result with the re module
Firstly, thanks a lot for your patient explanation.
this time I have understood all your points perfectly.
Secondly, I'd like to clarify some of my points, which
did not get through because of my poor prese
On 2/11/2010 8:53 AM, Yingjie Lan wrote:
BUT, but.
1. I expected findall to find matches of the whole
regex '(.a.)+', not just the subgroup (.a.) from
re.findall('(.a.)+', 'Mary has a lamb')
Thus it is probably a misunderstanding/bug??
Again, as soon as you put a capturing group in your exp
> From: John Bond
> You might wonder why something that can match no input
> text, doesn't return an infinite number of those matches at
> every possible position, but they would be overlapping, and
> findall explicitly says matches have to be non-overlapping.
That scrabbed my itches, though the
On 2/11/2010 7:00 AM, Yingjie Lan wrote:
re.findall('(.a.)*',' ') #two spaces
['', '', '']
I must need more details of the matching algorithm to explain this?
Regards,
Yingjie
Sorry - I hit enter prematurely on my last message.
To take the above as an example (all your examples boil dow
> From: John Bond
> Subject: Re: Why this result with the re module
> >>>> re.findall('(.a.)*', 'Mary has a lamb')
> > ['Mar', '', '', 'lam', '', '']
> So - see if you can explain the
> From: John Bond
> re.findall('(.a.)+', 'Mary has a lamb')
> > ['Mar', 'lam']
> It's because you're using capturing groups, and because of
> how they work - specifically they only return the LAST match
> if used with repetition (and multiple matches occur).
It seems capturing groups is ass
On 2/11/2010 4:31 AM, Yingjie Lan wrote:
Hi, I am rather confused by these results below.
I am not a re expert at all. the module version
of re is 2.2.1 with python 3.1.2
import re
re.findall('.a.', 'Mary has a lamb') #OK
['Mar', 'has', ' a ', 'lam']
re.findall('(.a.)*', 'Mary has a lamb') #?
10 matches
Mail list logo