On Tue, 21 Dec 2004 15:08:56 -0500, David McDowell
<[EMAIL PROTECTED]> wrote:
> Can you write a script that uses regex to compare each package name
> and its subsequent version number and if it has more than one, delete
> all other versions with a lower number?
> 
> pkg-2.4-5.i386.rpm
> pkg-2.4-6.i386.rpm
> pkg-2.7-1.i386.rpm
> 
> it would find "pkg" then the first "-" then the numbering and compare
> which is highest number and ditch the rest...
> 
> good luck... my regex fu is non-existent.  :)

Well, here's a regex that's used by a script that will automatically
mirror a mandrake distribution and only retrieve the latest version
of rpms.  It's somewhat mandrake specific and hard to understand,
but it might get you started:

my $regexp = 
'^.*\s((?:.*?(?=-\d+\.\d+\.\d+\.\d+mdk))|(?:.*?(?!-\d+\.\d+\.\d+\.\d+mdk)))-((?:\d+\.\d+\.\d+\.\d+m
dk)|(?:[^-]*-[^-]*(?!-)))((?:-1-1mdk\..*\.rpm)|(?:\.[^-]*\.rpm))$';

Good luck.

Cheers,
Tanner
-- 
TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
TriLUG Organizational FAQ  : http://trilug.org/faq/
TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
TriLUG PGP Keyring         : http://trilug.org/~chrish/trilug.asc

Reply via email to