Overlapping Regular Expression Matches With findall()

Simon Brunning simon at brunningonline.net
Thu Dec 15 15:33:42 EST 2005


On 15 Dec 2005 12:26:07 -0800, Mystilleef <mystilleef at gmail.com> wrote:
> I want a pattern that scans the entire string but avoids
> returning duplicate matches. For example "cat", "cate",
> "cater" may all well be valid matches, but I don't want
> duplicate matches of any of them. I know I can filter the
> list containing found matches myself, but that is somewhat
> expensive for a list containing thousands of matches.

Probably the cheapest way of de-duping the list would be to dump it
straight into a set, provided that you aren't concerned about the
order.

--
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/



More information about the Python-list mailing list