Why this result with the re module

Vlastimil Brom vlastimil.brom at gmail.com
Tue Nov 2 08:34:56 EDT 2010


2010/11/2 Yingjie Lan <lanyjie at yahoo.com>:
>> From: John Bond <lists at asd-group.com>
>> 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.
> And it will eliminate the need of returning tuples,
> and it is much more precise and information rich.
>
>
Hi,
in that case you may use re.finditer(...), which seem to provide, what
you need here. (It returns an iterator over the Match objects, which
can be easily fed to tuple(...) if it were needed.)

hth,
  vbr



More information about the Python-list mailing list