memtester port

Ryan Schmidt ryandesign at
Wed Jul 15 17:50:48 PDT 2009

On Jul 14, 2009, at 18:28, Scott Haneda wrote:

> livecheck.regex     	"${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"

On Jul 14, 2009, at 20:46, Jeremy Lavergne wrote:

> On Jul 14, 2009, at 7:28 PM, Scott Haneda wrote:
>> Here is my final port, my areas of concern are the livecheck  
>> regex.  That is a copy and paste from elsewhere, and I can not  
>> break it out.  You have to escape regex inside livecheck?
> Yes, if you use quotations, you must use double escapes. If you use  
> braces, then only one escape is needed.

Right. The first backslash escapes the next character from the Tcl  
interpreter. The second backslash escapes the next character from the  
regular expression interpreter. If you use a Tcl curlybrace-enclosed  
string instead of a doublequote-enclosed string, you don't use the  
extra level of escaping.

>> So d+ is all numbers, that ?: is a mystery to me, and then a dot,  
>> and then a digit, and then aything. I have three distinct version  
>> digits, so there may be some altering that needs to happen here.   
>> Perhaps the * means, match the pattern of digit and dot as many  
>> times as it happens?
> The d is "one numeric digit or more."

To be precise, "\d" is a single "digit 0 thru 9".

"+" means "one or more of the preceding".

So "\d+" is "one or more digits 0 thru 9".

> The ?: basically means find the first one and stop -- saves on  
> speed and memory versus matching the whole line.

No, "?:", when it is the first thing inside parentheses, means the  
parentheses only group but are not remembered as a backreference.  
It's pretty irrelevant in this case. Livecheck only makes use of the  
first remembered parentheses (which it uses as the version number)  
and any subsequent remembered parentheses are not used at all.

> * means 0 or more (and finally ? means 0 or 1 -- that's ? + and *  
> quantifiers).

Right. So all together, the remembered part for the version number is:


meaning: one or more digits, followed by zero or more period-followed- 

The period has a backslash before it because otherwise it doesn't  
mean a period; it means "any character".

I personally use the simpler


meaning: one or more digit-or-period.

This period does not have a backslash before it because it is inside  
a character class (the square brackets).

There are many ways to skin a cat with regular expressions. And there  
are many references that will teach you all about regular  
expressions, and I encourage you to find one and read all about them.  
They take a bit of getting used to but once you know the syntax  
they're very powerful.

>> Any other suggestions before I ship it off to trac?
> Does it pass `port lint --nitpick memtester`?

IMHO passing "port lint" is sufficient. "--nitpick" is, well, nit- 
picky, and I don't have a problem with ports not conforming to it.

More information about the macports-dev mailing list