[Fredrik] > so re.sub("([_.])\\1+", "\\1", newname) replaces runs consisting > of either a . or an _ followed by one or more copies of itself, with > a single instance of itself. ...and this: >>> def isprime(n): >>> return n > 1 and not re.match(r'(xx+)\1+$', 'x'*n) finds prime numbers. I'll get me coat. -- Richie Hindle richie at entrian.com