Re: Need version regex
by bart (Canon) on Nov 26, 2004 at 20:31 UTC
|
I don't think that's very practical. You're better off, IMO, to extract a version number, and compare it to your limit value, external to the regex. Trying to incorporate the comparison inside the regex, isn't very useful, IMO, but it is very hard, if it is even feasable. | [reply] |
|
|
Sorry can't do. Because the only comparision in sed I can do is regex match. (See first sentence in original post and my answer to samtgear above)
| [reply] |
Re: Need version regex
by ysth (Canon) on Nov 26, 2004 at 20:56 UTC
|
In perl regexes, you can place comments inside (?# ... ); I'd place your original version there; should be easy to extract again from the stringized qr//. As for all the rest, you need to specify what forms version numbers can take and what "higher" and "lower" mean. I'm guessing maybe you want versions to be strings of digits separated by strings of non-digits, and to apply a few rules:
A series of strings of digits is greater than another series of strings of digits if the series starts with 0 or more strings of digits numerically equal to the corresponding ones followed by a string of digits that is numerically greater than the corresponding one.
A version is higher if the leading series of strings of digits that has separating non-digits equal to the corresponding ones is greater than the corresponding series.
A versions is equal if its strings of digits are all numerically equal and strings of non-digits are equal to the corresponding ones.
I leave to you or others coming up with a regex. | [reply] |
Re: Need version regex
by BrowserUk (Patriarch) on Nov 26, 2004 at 21:06 UTC
|
Like others, I find the wording of your question quite confusing.
However, I did recall a similar sounding question from some time ago. You might find my answer or one of the other approaches in the thread of use to you.
Examine what is said, not who speaks.
"But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
"Think for yourself!" - Abigail
"Time is a poor substitute for thought"--theorbtwo
"Efficiency is intelligent laziness." -David Dunham
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
| [reply] |
|
|
The problem is doing this with regexes (not the expanding but the comparision) and I dont like arbitrary limits. For instance 5 is way too low for wine (the programs version numbers I mean)
| [reply] |
Re: Need version regex
by samtregar (Abbot) on Nov 26, 2004 at 20:26 UTC
|
Maybe my brain is running slow due to turkey overload, but I don't think you're making sense. What problem are you trying to solve?
It sounds like you're trying to create a regex that matches some set of version numbers, but beyond that I'm lost. What does it mean for a regex to "1:1 carry any information in a given version number"? What does it mean for two regexes to "match each other"?
Slow down and spell it out. If you're really looking for a regex show us some samples of what it should match and what it should not match.
-sam
| [reply] |
|
|
OK, here is what I try to accomplish. I want to create a package system (like rpm for example) which could be used for very minimal installations. That system should work down to "uninstall rm". So this system can't be dependent on large packages like perl. Of course one could use perl to create the packages. The database must store the version numbers. That means "1:1...". But I don't need to store them in a form unsuitable to matches. I want to use sed to extract information from this packageDB. sed because no other program is likely to be installed then. So I want the version numbers in a form that sed can use for comparision. That is a regex. Regexes match strings. Regexes are represented (in packageDB at least) as strings. Regexes could match a string that represents another (or the same) regex. If that match works is in version regexes a sign of order. That means "A regex matches a regex". Something I had left out: There could be a regex that matches all version regexes and is matched by them in turn so is equal to all -> a wildcard. That is another bonus for regexes, or have you ever heard of a wildcard number?Slow enough?
| [reply] |
|
|
OK, here is what I try to accomplish. I want to create a package system (like rpm for example) which could be used for very minimal installations. That system should work down to "uninstall rm". So this system can't be dependent on large packages like perl. Of course one could use perl to create the packages. The database must store the version numbers. That means "1:1...". But I don't need to store them in a form unsuitable to matches. I want to use sed to extract information from this packageDB. sed because no other program is likely to be installed then. So I want the version numbers in a form that sed can use for comparision.
Ok, this sounds reasonable enough. I personally won't work on a system so archaic that it doesn't come with Perl installed, but I guess some people might.
That is a regex.
Hold up here. You just lost me. You want to store the version number as a regex? Whatever for? I can think of a number of simpler ways to accomplish your goals. How about a tiny C program that parses version numbers and does the comparison? Then you won't even need sed! Or do it using /bin/sh for that old-timey appeal.
That is another bonus for regexes, or have you ever heard of a wildcard number?
Well, I've heard of wildcards and I've heard of numbers... But a "wildcard number"? No, can't say that I have.
-sam
| [reply] |
|
|