Need programming tip

Alex Martelli aleaxit at
Sun Jan 30 03:52:07 EST 2005

<ssaeed1973 at> wrote:
> 1511156       As Requested 2000 adv server -2000AdvSrv.vol001+02.PAR2 (1/4) -
> 21/27
> 1511157       As Requested 2000 adv server -2000AdvSrv.vol001+02.PAR2 (2/4) -
> 21/27
> would be to look for (1/ in the subject string then find the
> denominator and loop thru as many times as the denominator to create
> the <segment> part of the nzb file. Is this the best way or is there an
> easier method? Also what would be the best way to search for the (1/
> using string searches or RegExp? If REgExp could someone provide me
> with the RegExp for searching for this string?

If the only thing that identifies these posts as part of one logical
post is that (n/m) in the subject then I guess there's nothing for it
but analysis of the subject, and a re seems appropriate.

import re
re_n_of_m = re.compile(r'(.*)\s*\((\d+)/(\d+)\)')

might be one approach.   Then, somewhere in your loop,

mo =

sets mo to None if it doesn't match the pattern; if it does match, then
mo is a match object with three groups. is the part of the
subject before the (n/m) marker; is n as a string; is n as a string.  You can use as the key into a
dictionary where you collect (n,m) pairs as values, so that once you've
collected all posts you can tell which one are multipart and also check
for inconsistency (different m values), duplicates, missing parts.  What
you need to do in each case, I don't know...


More information about the Python-list mailing list