regular expression match collection
Steve Holden
steve at holdenweb.com
Fri Feb 4 09:28:31 EST 2005
ajikoe at gmail.com wrote:
> Hello,
>
> For example I have a string : "Halo by by by"
> Then I want to take and know the possition of every "by"
> how can I do it in python?
>
> I tried to use:
>
> p = re.compile(r"by")
> m = p.search("Helo by by by")
> print m.group() # result "by"
> print m.span() # result (5,7)
>
> How can I get the information of the other by ?
>
> Sincerely Yours,
> Pujo Aji
>
You need re.findall() (or, equivalently, the findall() method of an re).
regards
Steve
--
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005 http://www.pycon.org/
Steve Holden http://www.holdenweb.com/
More information about the Python-list
mailing list