Re: Regular Expression for Versions

On Tue, May 02, 2000 at 08:14:53PM -0400, Sean Thomas Middleditch wrote:
> I'm using -(\d.)+\. now... it matches -1.0.58. from
> gnome-libs-1.0.58.tar.gz for example, then I strip off the leading - and
> trailing . .  This is ALSO my first time trying to use regular
> expressions, so I fear I'm not doing too good of a job.  ;-)  Some
> packages, like gdm-2.0beta4.tar.gz and gnome-hack_1.0.1-1.tar.gz fail.
> I need a way of also grabbing that last number following a - , and a way
> of grabbing stuff after a pre or beta or whatever (like the gdm
> example).  This would make the version grabbing a lot easier.  Then I
> could do stuff like comparing the current versions in the directory with
> the file to be downloaded to see if the one you have is newer (like most
> of my files, since I only work with the development packages).

How about
(\d.+)\.tar (or (\d.+)\.(tar|rpm) if you want to be able to use rpm:s as
and then in the first sub expression you should have what you are looking
for. (group(1) in python I think :))

You might want to check our regexplorer.  It's kinda cool eventhough it's
a QT-program.  Helps you alot in writing regexp.

Erik Bågfors               | Center for Parallel Computers    |            |  
Supporter of free software | GSM +46 70 398 54 43 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]